<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module Kernel - RDoc Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#module-Kernel-label-What-27s+Here">What’s Here</a>
    <li><a href="#module-Kernel-label-Converting">Converting</a>
    <li><a href="#module-Kernel-label-Querying">Querying</a>
    <li><a href="#module-Kernel-label-Exiting">Exiting</a>
    <li><a href="#module-Kernel-label-Exceptions">Exceptions</a>
    <li><a href="#module-Kernel-label-IO">IO</a>
    <li><a href="#module-Kernel-label-Procs">Procs</a>
    <li><a href="#module-Kernel-label-Tracing">Tracing</a>
    <li><a href="#module-Kernel-label-Subprocesses">Subprocesses</a>
    <li><a href="#module-Kernel-label-Loading">Loading</a>
    <li><a href="#module-Kernel-label-Yielding">Yielding</a>
    <li><a href="#module-Kernel-label-Random+Values">Random Values</a>
    <li><a href="#module-Kernel-label-Other">Other</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-i-Array">#Array</a>
    <li ><a href="#method-i-Complex">#Complex</a>
    <li ><a href="#method-i-Float">#Float</a>
    <li ><a href="#method-i-Hash">#Hash</a>
    <li ><a href="#method-i-Integer">#Integer</a>
    <li ><a href="#method-i-Rational">#Rational</a>
    <li ><a href="#method-i-String">#String</a>
    <li ><a href="#method-i-__callee__">#__callee__</a>
    <li ><a href="#method-i-__dir__">#__dir__</a>
    <li ><a href="#method-i-__method__">#__method__</a>
    <li ><a href="#method-i-60">#`</a>
    <li ><a href="#method-i-abort">#abort</a>
    <li ><a href="#method-i-at_exit">#at_exit</a>
    <li ><a href="#method-i-autoload">#autoload</a>
    <li ><a href="#method-i-autoload-3F">#autoload?</a>
    <li ><a href="#method-i-binding">#binding</a>
    <li ><a href="#method-i-block_given-3F">#block_given?</a>
    <li ><a href="#method-i-callcc">#callcc</a>
    <li ><a href="#method-i-caller">#caller</a>
    <li ><a href="#method-i-caller_locations">#caller_locations</a>
    <li ><a href="#method-i-catch">#catch</a>
    <li ><a href="#method-i-chomp">#chomp</a>
    <li ><a href="#method-i-chop">#chop</a>
    <li ><a href="#method-i-class">#class</a>
    <li ><a href="#method-i-clone">#clone</a>
    <li ><a href="#method-i-eval">#eval</a>
    <li ><a href="#method-i-exec">#exec</a>
    <li ><a href="#method-i-exit">#exit</a>
    <li ><a href="#method-i-exit-21">#exit!</a>
    <li ><a href="#method-i-fail">#fail</a>
    <li ><a href="#method-i-fork">#fork</a>
    <li ><a href="#method-i-format">#format</a>
    <li ><a href="#method-i-frozen-3F">#frozen?</a>
    <li ><a href="#method-i-gets">#gets</a>
    <li ><a href="#method-i-global_variables">#global_variables</a>
    <li ><a href="#method-i-gsub">#gsub</a>
    <li ><a href="#method-i-iterator-3F">#iterator?</a>
    <li ><a href="#method-i-lambda">#lambda</a>
    <li ><a href="#method-i-load">#load</a>
    <li ><a href="#method-i-local_variables">#local_variables</a>
    <li ><a href="#method-i-loop">#loop</a>
    <li ><a href="#method-i-open">#open</a>
    <li ><a href="#method-i-p">#p</a>
    <li ><a href="#method-i-pp">#pp</a>
    <li ><a href="#method-i-print">#print</a>
    <li ><a href="#method-i-printf">#printf</a>
    <li ><a href="#method-i-proc">#proc</a>
    <li ><a href="#method-i-putc">#putc</a>
    <li ><a href="#method-i-puts">#puts</a>
    <li ><a href="#method-i-raise">#raise</a>
    <li ><a href="#method-i-rand">#rand</a>
    <li ><a href="#method-i-readline">#readline</a>
    <li ><a href="#method-i-readlines">#readlines</a>
    <li ><a href="#method-i-require">#require</a>
    <li ><a href="#method-i-require_relative">#require_relative</a>
    <li ><a href="#method-i-select">#select</a>
    <li ><a href="#method-i-set_trace_func">#set_trace_func</a>
    <li ><a href="#method-i-sleep">#sleep</a>
    <li ><a href="#method-i-spawn">#spawn</a>
    <li ><a href="#method-i-sprintf">#sprintf</a>
    <li ><a href="#method-i-srand">#srand</a>
    <li ><a href="#method-i-sub">#sub</a>
    <li ><a href="#method-i-syscall">#syscall</a>
    <li ><a href="#method-i-system">#system</a>
    <li ><a href="#method-i-tap">#tap</a>
    <li ><a href="#method-i-test">#test</a>
    <li ><a href="#method-i-then">#then</a>
    <li ><a href="#method-i-throw">#throw</a>
    <li ><a href="#method-i-trace_var">#trace_var</a>
    <li ><a href="#method-i-trap">#trap</a>
    <li ><a href="#method-i-untrace_var">#untrace_var</a>
    <li ><a href="#method-i-warn">#warn</a>
    <li ><a href="#method-i-yield_self">#yield_self</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-Kernel">
    <h1 id="module-Kernel" class="module">
      module Kernel
    </h1>

    <section class="description">
    
<p>The <a href="Kernel.html"><code>Kernel</code></a> module is included by class <a href="Object.html"><code>Object</code></a>, so its methods are available in every Ruby object.</p>

<p>The <a href="Kernel.html"><code>Kernel</code></a> instance methods are documented in class <a href="Object.html"><code>Object</code></a> while the module methods are documented here.  These methods are called without a receiver and thus can be called in functional form:</p>

<pre class="ruby"><span class="ruby-identifier">sprintf</span> <span class="ruby-string">&quot;%.1f&quot;</span>, <span class="ruby-value">1.234</span> <span class="ruby-comment">#=&gt; &quot;1.2&quot;</span>
</pre>

<h2 id="module-Kernel-label-What-27s+Here">What’s Here<span><a href="#module-Kernel-label-What-27s+Here">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Module Kernel provides methods that are useful for:</p>
<ul><li>
<p><a href="Kernel.html#module-Kernel-label-Converting">Converting</a></p>
</li><li>
<p><a href="Kernel.html#module-Kernel-label-Querying">Querying</a></p>
</li><li>
<p><a href="Kernel.html#module-Kernel-label-Exiting">Exiting</a></p>
</li><li>
<p><a href="Kernel.html#module-Kernel-label-Exceptions">Exceptions</a></p>
</li><li>
<p><a href="Kernel.html#module-Kernel-label-IO">IO</a></p>
</li><li>
<p><a href="Kernel.html#module-Kernel-label-Procs">Procs</a></p>
</li><li>
<p><a href="Kernel.html#module-Kernel-label-Tracing">Tracing</a></p>
</li><li>
<p><a href="Kernel.html#module-Kernel-label-Subprocesses">Subprocesses</a></p>
</li><li>
<p><a href="Kernel.html#module-Kernel-label-Loading">Loading</a></p>
</li><li>
<p><a href="Kernel.html#module-Kernel-label-Yielding">Yielding</a></p>
</li><li>
<p><a href="Kernel.html#module-Kernel-label-Random+Values">Random Values</a></p>
</li><li>
<p><a href="Kernel.html#module-Kernel-label-Other">Other</a></p>
</li></ul>

<h3 id="module-Kernel-label-Converting">Converting<span><a href="#module-Kernel-label-Converting">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="Kernel.html#method-i-Array"><code>Array</code></a>: Returns an <a href="Array.html"><code>Array</code></a> based on the given argument.</p>
</li><li>
<p><a href="Kernel.html#method-i-Complex"><code>Complex</code></a>: Returns a <a href="Complex.html"><code>Complex</code></a> based on the given arguments.</p>
</li><li>
<p><a href="Kernel.html#method-i-Float"><code>Float</code></a>: Returns a <a href="Float.html"><code>Float</code></a> based on the given arguments.</p>
</li><li>
<p><a href="Kernel.html#method-i-Hash"><code>Hash</code></a>: Returns a <a href="Hash.html"><code>Hash</code></a> based on the given argument.</p>
</li><li>
<p><a href="Kernel.html#method-i-Integer"><code>Integer</code></a>: Returns an <a href="Integer.html"><code>Integer</code></a> based on the given arguments.</p>
</li><li>
<p><a href="Kernel.html#method-i-Rational"><code>Rational</code></a>: Returns a <a href="Rational.html"><code>Rational</code></a> based on the given arguments.</p>
</li><li>
<p><a href="Kernel.html#method-i-String"><code>String</code></a>: Returns a <a href="String.html"><code>String</code></a> based on the given argument.</p>
</li></ul>

<h3 id="module-Kernel-label-Querying">Querying<span><a href="#module-Kernel-label-Querying">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p>#__callee__: Returns the called name of the current method as a symbol.</p>
</li><li>
<p>#__dir__: Returns the path to the directory from which the current method is called.</p>
</li><li>
<p>#__method__: Returns the name of the current method as a symbol.</p>
</li><li>
<p><a href="Kernel.html#method-i-autoload-3F"><code>autoload?</code></a>: Returns the file to be loaded when the given module is referenced.</p>
</li><li>
<p><a href="Kernel.html#method-i-binding"><code>binding</code></a>: Returns a <a href="Binding.html"><code>Binding</code></a> for the context at the point of call.</p>
</li><li>
<p><a href="Kernel.html#method-i-block_given-3F"><code>block_given?</code></a>: Returns <code>true</code> if a block was passed to the calling method.</p>
</li><li>
<p><a href="Kernel.html#method-i-caller"><code>caller</code></a>: Returns the current execution stack as an array of strings.</p>
</li><li>
<p><a href="Kernel.html#method-i-caller_locations"><code>caller_locations</code></a>: Returns the current execution stack as an array of <a href="Thread/Backtrace/Location.html"><code>Thread::Backtrace::Location</code></a> objects.</p>
</li><li>
<p><a href="Kernel.html#method-i-class"><code>class</code></a>: Returns the class of <code>self</code>.</p>
</li><li>
<p><a href="Kernel.html#method-i-frozen-3F"><code>frozen?</code></a>: Returns whether <code>self</code> is frozen.</p>
</li><li>
<p><a href="Kernel.html#method-i-global_variables"><code>global_variables</code></a>: Returns an array of global variables as symbols.</p>
</li><li>
<p><a href="Kernel.html#method-i-local_variables"><code>local_variables</code></a>: Returns an array of local variables as symbols.</p>
</li><li>
<p><a href="Kernel.html#method-i-test"><code>test</code></a>: Performs specified tests on the given single file or pair of files.</p>
</li></ul>

<h3 id="module-Kernel-label-Exiting">Exiting<span><a href="#module-Kernel-label-Exiting">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="Kernel.html#method-i-abort"><code>abort</code></a>: Exits the current process after printing the given arguments.</p>
</li><li>
<p><a href="Kernel.html#method-i-at_exit"><code>at_exit</code></a>: Executes the given block when the process exits.</p>
</li><li>
<p><a href="Kernel.html#method-i-exit"><code>exit</code></a>: Exits the current process after calling any registered <code>at_exit</code> handlers.</p>
</li><li>
<p><a href="Kernel.html#method-i-exit-21"><code>exit!</code></a>: Exits the current process without calling any registered <code>at_exit</code> handlers.</p>
</li></ul>

<h3 id="module-Kernel-label-Exceptions">Exceptions<span><a href="#module-Kernel-label-Exceptions">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="Kernel.html#method-i-catch"><code>catch</code></a>: Executes the given block, possibly catching a thrown object.</p>
</li><li>
<p><a href="Kernel.html#method-i-raise"><code>raise</code></a> (aliased as <a href="Kernel.html#method-i-fail"><code>fail</code></a>): Raises an exception based on the given arguments.</p>
</li><li>
<p><a href="Kernel.html#method-i-throw"><code>throw</code></a>: Returns from the active catch block waiting for the given tag.</p>
</li></ul>

<h3 id="module-Kernel-label-IO">IO<span><a href="#module-Kernel-label-IO">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p>::pp: Prints the given objects in pretty form.</p>
</li><li>
<p><a href="Kernel.html#method-i-gets"><code>gets</code></a>: Returns and assigns to <code>$_</code> the next line from the current input.</p>
</li><li>
<p><a href="Kernel.html#method-i-open"><code>open</code></a>: Creates an <a href="IO.html"><code>IO</code></a> object connected to the given stream, file, or subprocess.</p>
</li><li>
<p><a href="Kernel.html#method-i-p"><code>p</code></a>:  Prints the given objects’ inspect output to the standard output.</p>
</li><li>
<p><a href="Kernel.html#method-i-print"><code>print</code></a>: Prints the given objects to standard output without a newline.</p>
</li><li>
<p><a href="Kernel.html#method-i-printf"><code>printf</code></a>: Prints the string resulting from applying the given format string to any additional arguments.</p>
</li><li>
<p><a href="Kernel.html#method-i-putc"><code>putc</code></a>: Equivalent to &lt;tt.$stdout.putc(object)&lt;/tt&gt; for the given object.</p>
</li><li>
<p><a href="Kernel.html#method-i-puts"><code>puts</code></a>: Equivalent to <code>$stdout.puts(*objects)</code> for the given objects.</p>
</li><li>
<p><a href="Kernel.html#method-i-readline"><code>readline</code></a>: Similar to <a href="Kernel.html#method-i-gets"><code>gets</code></a>, but raises an exception at the end of file.</p>
</li><li>
<p><a href="Kernel.html#method-i-readlines"><code>readlines</code></a>: Returns an array of the remaining lines from the current input.</p>
</li><li>
<p><a href="Kernel.html#method-i-select"><code>select</code></a>: Same as <a href="IO.html#method-c-select"><code>IO.select</code></a>.</p>
</li></ul>

<h3 id="module-Kernel-label-Procs">Procs<span><a href="#module-Kernel-label-Procs">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="Kernel.html#method-i-lambda"><code>lambda</code></a>: Returns a lambda proc for the given block.</p>
</li><li>
<p><a href="Kernel.html#method-i-proc"><code>proc</code></a>: Returns a new <a href="Proc.html"><code>Proc</code></a>; equivalent to <a href="Proc.html#method-c-new"><code>Proc.new</code></a>.</p>
</li></ul>

<h3 id="module-Kernel-label-Tracing">Tracing<span><a href="#module-Kernel-label-Tracing">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="Kernel.html#method-i-set_trace_func"><code>set_trace_func</code></a>: Sets the given proc as the handler for tracing, or disables tracing if given <code>nil</code>.</p>
</li><li>
<p><a href="Kernel.html#method-i-trace_var"><code>trace_var</code></a>: Starts tracing assignments to the given global variable.</p>
</li><li>
<p><a href="Kernel.html#method-i-untrace_var"><code>untrace_var</code></a>: Disables tracing of assignments to the given global variable.</p>
</li></ul>

<h3 id="module-Kernel-label-Subprocesses">Subprocesses<span><a href="#module-Kernel-label-Subprocesses">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p>`command`: Returns the standard output of running <code>command</code> in a subshell.</p>
</li><li>
<p><a href="Kernel.html#method-i-exec"><code>exec</code></a>: Replaces current process with a new process.</p>
</li><li>
<p><a href="Kernel.html#method-i-fork"><code>fork</code></a>: Forks the current process into two processes.</p>
</li><li>
<p><a href="Kernel.html#method-i-spawn"><code>spawn</code></a>: Executes the given command and returns its pid without waiting for completion.</p>
</li><li>
<p><a href="Kernel.html#method-i-system"><code>system</code></a>: Executes the given command in a subshell.</p>
</li></ul>

<h3 id="module-Kernel-label-Loading">Loading<span><a href="#module-Kernel-label-Loading">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="Kernel.html#method-i-autoload"><code>autoload</code></a>: Registers the given file to be loaded when the given constant is first referenced.</p>
</li><li>
<p><a href="Kernel.html#method-i-load"><code>load</code></a>: Loads the given Ruby file.</p>
</li><li>
<p><a href="Kernel.html#method-i-require"><code>require</code></a>: Loads the given Ruby file unless it has already been loaded.</p>
</li><li>
<p><a href="Kernel.html#method-i-require_relative"><code>require_relative</code></a>: Loads the Ruby file path relative to the calling file, unless it has already been loaded.</p>
</li></ul>

<h3 id="module-Kernel-label-Yielding">Yielding<span><a href="#module-Kernel-label-Yielding">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="Kernel.html#method-i-tap"><code>tap</code></a>: Yields <code>self</code> to the given block; returns <code>self</code>.</p>
</li><li>
<p><a href="Kernel.html#method-i-then"><code>then</code></a> (aliased as <a href="Kernel.html#method-i-yield_self"><code>yield_self</code></a>): Yields <code>self</code> to the block and returns the result of the block.</p>
</li></ul>

<h3 id="module-Kernel-label-Random+Values">Random Values<span><a href="#module-Kernel-label-Random+Values">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="Kernel.html#method-i-rand"><code>rand</code></a>: Returns a pseudo-random floating point number strictly between 0.0 and 1.0.</p>
</li><li>
<p><a href="Kernel.html#method-i-srand"><code>srand</code></a>: Seeds the pseudo-random number generator with the given number.</p>
</li></ul>

<h3 id="module-Kernel-label-Other">Other<span><a href="#module-Kernel-label-Other">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="Kernel.html#method-i-eval"><code>eval</code></a>: Evaluates the given string as Ruby code.</p>
</li><li>
<p><a href="Kernel.html#method-i-loop"><code>loop</code></a>: Repeatedly executes the given block.</p>
</li><li>
<p><a href="Kernel.html#method-i-sleep"><code>sleep</code></a>: Suspends the current thread for the given number of seconds.</p>
</li><li>
<p><a href="Kernel.html#method-i-sprintf"><code>sprintf</code></a> (aliased as <a href="Kernel.html#method-i-format"><code>format</code></a>): Returns the string resulting from applying the given format string to any additional arguments.</p>
</li><li>
<p><a href="Kernel.html#method-i-syscall"><code>syscall</code></a>: Runs an operating system call.</p>
</li><li>
<p><a href="Kernel.html#method-i-trap"><code>trap</code></a>: Specifies the handling of system signals.</p>
</li><li>
<p><a href="Kernel.html#method-i-warn"><code>warn</code></a>: Issue a warning based on the given messages and options.</p>
</li></ul>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-Array" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          Array(object) &rarr; object or new_array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array converted from <code>object</code>.</p>

<p>Tries to convert <code>object</code> to an array using <code>to_ary</code> first and <code>to_a</code> second:</p>

<pre class="ruby"><span class="ruby-constant">Array</span>([<span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">2</span>])        <span class="ruby-comment"># =&gt; [0, 1, 2]</span>
<span class="ruby-constant">Array</span>({<span class="ruby-value">foo:</span> <span class="ruby-value">0</span>, <span class="ruby-value">bar:</span> <span class="ruby-value">1</span>}) <span class="ruby-comment"># =&gt; [[:foo, 0], [:bar, 1]]</span>
<span class="ruby-constant">Array</span>(<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">4</span>)             <span class="ruby-comment"># =&gt; [0, 1, 2, 3, 4]</span>
</pre>

<p>Returns <code>object</code> in an array, <code>[object]</code>, if <code>object</code> cannot be converted:</p>

<pre class="ruby"><span class="ruby-constant">Array</span>(<span class="ruby-value">:foo</span>)             <span class="ruby-comment"># =&gt; [:foo]</span>
</pre>

                              <div class="method-source-code" id="Array-source">
            <pre>static VALUE
rb_f_array(VALUE obj, VALUE arg)
{
    return rb_Array(arg);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-Complex" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          Complex(x[, y], exception: true)  &rarr;  numeric or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns x+i*y;</p>

<pre class="ruby"><span class="ruby-constant">Complex</span>(<span class="ruby-value">1</span>, <span class="ruby-value">2</span>)    <span class="ruby-comment">#=&gt; (1+2i)</span>
<span class="ruby-constant">Complex</span>(<span class="ruby-string">&#39;1+2i&#39;</span>)  <span class="ruby-comment">#=&gt; (1+2i)</span>
<span class="ruby-constant">Complex</span>(<span class="ruby-keyword">nil</span>)     <span class="ruby-comment">#=&gt; TypeError</span>
<span class="ruby-constant">Complex</span>(<span class="ruby-value">1</span>, <span class="ruby-keyword">nil</span>)  <span class="ruby-comment">#=&gt; TypeError</span>

<span class="ruby-constant">Complex</span>(<span class="ruby-value">1</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-value">exception:</span> <span class="ruby-keyword">false</span>)  <span class="ruby-comment">#=&gt; nil</span>
<span class="ruby-constant">Complex</span>(<span class="ruby-string">&#39;1+2&#39;</span>, <span class="ruby-value">exception:</span> <span class="ruby-keyword">false</span>)   <span class="ruby-comment">#=&gt; nil</span>
</pre>

<p>Syntax of string form:</p>

<pre>string form = extra spaces , complex , extra spaces ;
complex = real part | [ sign ] , imaginary part
        | real part , sign , imaginary part
        | rational , &quot;@&quot; , rational ;
real part = rational ;
imaginary part = imaginary unit | unsigned rational , imaginary unit ;
rational = [ sign ] , unsigned rational ;
unsigned rational = numerator | numerator , &quot;/&quot; , denominator ;
numerator = integer part | fractional part | integer part , fractional part ;
denominator = digits ;
integer part = digits ;
fractional part = &quot;.&quot; , digits , [ ( &quot;e&quot; | &quot;E&quot; ) , [ sign ] , digits ] ;
imaginary unit = &quot;i&quot; | &quot;I&quot; | &quot;j&quot; | &quot;J&quot; ;
sign = &quot;-&quot; | &quot;+&quot; ;
digits = digit , { digit | &quot;_&quot; , digit };
digit = &quot;0&quot; | &quot;1&quot; | &quot;2&quot; | &quot;3&quot; | &quot;4&quot; | &quot;5&quot; | &quot;6&quot; | &quot;7&quot; | &quot;8&quot; | &quot;9&quot; ;
extra spaces = ? \s* ? ;</pre>

<p>See <a href="String.html#method-i-to_c"><code>String#to_c</code></a>.</p>

                              <div class="method-source-code" id="Complex-source">
            <pre>static VALUE
nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
{
    VALUE a1, a2, opts = Qnil;
    int raise = TRUE;

    if (rb_scan_args(argc, argv, &quot;11:&quot;, &amp;a1, &amp;a2, &amp;opts) == 1) {
        a2 = Qundef;
    }
    if (!NIL_P(opts)) {
        raise = rb_opts_exception_p(opts, raise);
    }
    if (argc &gt; 0 &amp;&amp; CLASS_OF(a1) == rb_cComplex &amp;&amp; UNDEF_P(a2)) {
        return a1;
    }
    return nucomp_convert(rb_cComplex, a1, a2, raise);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-Float" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          Float(arg, exception: true)    &rarr; float or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <em>arg</em> converted to a float. <a href="Numeric.html"><code>Numeric</code></a> types are converted directly, and with exception to <a href="String.html"><code>String</code></a> and <code>nil</code> the rest are converted using <em>arg</em><code>.to_f</code>.  Converting a <a href="String.html"><code>String</code></a> with invalid characters will result in a <a href="ArgumentError.html"><code>ArgumentError</code></a>.  Converting <code>nil</code> generates a <a href="TypeError.html"><code>TypeError</code></a>.  Exceptions can be suppressed by passing <code>exception: false</code>.</p>

<pre class="ruby"><span class="ruby-constant">Float</span>(<span class="ruby-value">1</span>)                 <span class="ruby-comment">#=&gt; 1.0</span>
<span class="ruby-constant">Float</span>(<span class="ruby-string">&quot;123.456&quot;</span>)         <span class="ruby-comment">#=&gt; 123.456</span>
<span class="ruby-constant">Float</span>(<span class="ruby-string">&quot;123.0_badstring&quot;</span>) <span class="ruby-comment">#=&gt; ArgumentError: invalid value for Float(): &quot;123.0_badstring&quot;</span>
<span class="ruby-constant">Float</span>(<span class="ruby-keyword">nil</span>)               <span class="ruby-comment">#=&gt; TypeError: can&#39;t convert nil into Float</span>
<span class="ruby-constant">Float</span>(<span class="ruby-string">&quot;123.0_badstring&quot;</span>, <span class="ruby-value">exception:</span> <span class="ruby-keyword">false</span>)  <span class="ruby-comment">#=&gt; nil</span>
</pre>

                              <div class="method-source-code" id="Float-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/kernel.rb, line 212</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Float</span>(<span class="ruby-identifier ruby-title">arg</span>, <span class="ruby-value">exception:</span> <span class="ruby-keyword">true</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">mandatory_only?</span>
    <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_f_float1</span>(<span class="ruby-identifier">arg</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_f_float</span>(<span class="ruby-identifier">arg</span>, <span class="ruby-identifier">exception</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-Hash" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          Hash(object) &rarr; object or new_hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a hash converted from <code>object</code>.</p>
<ul><li>
<p>If <code>object</code> is:</p>
<ul><li>
<p>A hash, returns <code>object</code>.</p>
</li><li>
<p>An empty array or <code>nil</code>, returns an empty hash.</p>
</li></ul>
</li><li>
<p>Otherwise, if <code>object.to_hash</code> returns a hash, returns that hash.</p>
</li><li>
<p>Otherwise, returns <a href="TypeError.html"><code>TypeError</code></a>.</p>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-constant">Hash</span>({<span class="ruby-value">foo:</span> <span class="ruby-value">0</span>, <span class="ruby-value">bar:</span> <span class="ruby-value">1</span>}) <span class="ruby-comment"># =&gt; {:foo=&gt;0, :bar=&gt;1}</span>
<span class="ruby-constant">Hash</span>(<span class="ruby-keyword">nil</span>)              <span class="ruby-comment"># =&gt; {}</span>
<span class="ruby-constant">Hash</span>([])               <span class="ruby-comment"># =&gt; {}</span>
</pre>

                              <div class="method-source-code" id="Hash-source">
            <pre>static VALUE
rb_f_hash(VALUE obj, VALUE arg)
{
    return rb_Hash(arg);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-Integer" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          Integer(object, base = 0, exception: true) &rarr; integer or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an integer converted from <code>object</code>.</p>

<p>Tries to convert <code>object</code> to an integer using <code>to_int</code> first and <code>to_i</code> second; see below for exceptions.</p>

<p>With a non-zero <code>base</code>, <code>object</code> must be a string or convertible to a string.</p>

<h4 id="method-i-Integer-label-numeric+objects">numeric objects<span><a href="#method-i-Integer-label-numeric+objects">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>With integer argument <code>object</code> given, returns <code>object</code>:</p>

<pre class="ruby"><span class="ruby-constant">Integer</span>(<span class="ruby-value">1</span>)                <span class="ruby-comment"># =&gt; 1</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-value">-1</span>)               <span class="ruby-comment"># =&gt; -1</span>
</pre>

<p>With floating-point argument <code>object</code> given, returns <code>object</code> truncated to an integer:</p>

<pre class="ruby"><span class="ruby-constant">Integer</span>(<span class="ruby-value">1.9</span>)              <span class="ruby-comment"># =&gt; 1  # Rounds toward zero.</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-value">-1.9</span>)             <span class="ruby-comment"># =&gt; -1 # Rounds toward zero.</span>
</pre>

<h4 id="method-i-Integer-label-string+objects">string objects<span><a href="#method-i-Integer-label-string+objects">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>With string argument <code>object</code> and zero <code>base</code> given, returns <code>object</code> converted to an integer in base 10:</p>

<pre class="ruby"><span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;100&#39;</span>)    <span class="ruby-comment"># =&gt; 100</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;-100&#39;</span>)   <span class="ruby-comment"># =&gt; -100</span>
</pre>

<p>With <code>base</code> zero, string <code>object</code> may contain leading characters to specify the actual base (radix indicator):</p>

<pre class="ruby"><span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;0100&#39;</span>)  <span class="ruby-comment"># =&gt; 64  # Leading &#39;0&#39; specifies base 8.</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;0b100&#39;</span>) <span class="ruby-comment"># =&gt; 4   # Leading &#39;0b&#39;, specifies base 2.</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;0x100&#39;</span>) <span class="ruby-comment"># =&gt; 256 # Leading &#39;0x&#39; specifies base 16.</span>
</pre>

<p>With a positive <code>base</code> (in range 2..36) given, returns <code>object</code> converted to an integer in the given base:</p>

<pre class="ruby"><span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;100&#39;</span>, <span class="ruby-value">2</span>)   <span class="ruby-comment"># =&gt; 4</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;100&#39;</span>, <span class="ruby-value">8</span>)   <span class="ruby-comment"># =&gt; 64</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;-100&#39;</span>, <span class="ruby-value">16</span>) <span class="ruby-comment"># =&gt; -256</span>
</pre>

<p>With a negative <code>base</code> (in range -36..-2) given, returns <code>object</code> converted to an integer in the radix indicator if exists or <code>-base</code>:</p>

<pre class="ruby"><span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;0x100&#39;</span>, <span class="ruby-value">-2</span>)   <span class="ruby-comment"># =&gt; 256</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;100&#39;</span>, <span class="ruby-value">-2</span>)     <span class="ruby-comment"># =&gt; 4</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;0b100&#39;</span>, <span class="ruby-value">-8</span>)   <span class="ruby-comment"># =&gt; 4</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;100&#39;</span>, <span class="ruby-value">-8</span>)     <span class="ruby-comment"># =&gt; 64</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;0o100&#39;</span>, <span class="ruby-value">-10</span>)  <span class="ruby-comment"># =&gt; 64</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;100&#39;</span>, <span class="ruby-value">-10</span>)    <span class="ruby-comment"># =&gt; 100</span>
</pre>

<p><code>base</code> -1 is equal the -10 case.</p>

<p>When converting strings, surrounding whitespace and embedded underscores are allowed and ignored:</p>

<pre class="ruby"><span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39; 100 &#39;</span>)      <span class="ruby-comment"># =&gt; 100</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-string">&#39;-1_0_0&#39;</span>, <span class="ruby-value">16</span>) <span class="ruby-comment"># =&gt; -256</span>
</pre>

<h4 id="method-i-Integer-label-other+classes">other classes<span><a href="#method-i-Integer-label-other+classes">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Examples with <code>object</code> of various other classes:</p>

<pre class="ruby"><span class="ruby-constant">Integer</span>(<span class="ruby-constant">Rational</span>(<span class="ruby-value">9</span>, <span class="ruby-value">10</span>)) <span class="ruby-comment"># =&gt; 0  # Rounds toward zero.</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-constant">Complex</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>))   <span class="ruby-comment"># =&gt; 2  # Imaginary part must be zero.</span>
<span class="ruby-constant">Integer</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>)        <span class="ruby-comment"># =&gt; 1650974042</span>
</pre>

<h4 id="method-i-Integer-label-keywords">keywords<span><a href="#method-i-Integer-label-keywords">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>With optional keyword argument <code>exception</code> given as <code>true</code> (the default):</p>
<ul><li>
<p>Raises <a href="TypeError.html"><code>TypeError</code></a> if <code>object</code> does not respond to <code>to_int</code> or <code>to_i</code>.</p>
</li><li>
<p>Raises <a href="TypeError.html"><code>TypeError</code></a> if <code>object</code> is <code>nil</code>.</p>
</li><li>
<p>Raise <a href="ArgumentError.html"><code>ArgumentError</code></a> if <code>object</code> is an invalid string.</p>
</li></ul>

<p>With <code>exception</code> given as <code>false</code>, an exception of any kind is suppressed and <code>nil</code> is returned.</p>

                              <div class="method-source-code" id="Integer-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/kernel.rb, line 305</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Integer</span>(<span class="ruby-identifier ruby-title">arg</span>, <span class="ruby-identifier">base</span> = <span class="ruby-value">0</span>, <span class="ruby-value">exception:</span> <span class="ruby-keyword">true</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">mandatory_only?</span>
    <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_f_integer1</span>(<span class="ruby-identifier">arg</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_f_integer</span>(<span class="ruby-identifier">arg</span>, <span class="ruby-identifier">base</span>, <span class="ruby-identifier">exception</span>);
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-Rational" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          Rational(x, y, exception: true)  &rarr;  rational or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          Rational(arg, exception: true)   &rarr;  rational or nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>x/y</code> or <code>arg</code> as a <a href="Rational.html"><code>Rational</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">Rational</span>(<span class="ruby-value">2</span>, <span class="ruby-value">3</span>)   <span class="ruby-comment">#=&gt; (2/3)</span>
<span class="ruby-constant">Rational</span>(<span class="ruby-value">5</span>)      <span class="ruby-comment">#=&gt; (5/1)</span>
<span class="ruby-constant">Rational</span>(<span class="ruby-value">0.5</span>)    <span class="ruby-comment">#=&gt; (1/2)</span>
<span class="ruby-constant">Rational</span>(<span class="ruby-value">0.3</span>)    <span class="ruby-comment">#=&gt; (5404319552844595/18014398509481984)</span>

<span class="ruby-constant">Rational</span>(<span class="ruby-string">&quot;2/3&quot;</span>)  <span class="ruby-comment">#=&gt; (2/3)</span>
<span class="ruby-constant">Rational</span>(<span class="ruby-string">&quot;0.3&quot;</span>)  <span class="ruby-comment">#=&gt; (3/10)</span>

<span class="ruby-constant">Rational</span>(<span class="ruby-string">&quot;10 cents&quot;</span>)  <span class="ruby-comment">#=&gt; ArgumentError</span>
<span class="ruby-constant">Rational</span>(<span class="ruby-keyword">nil</span>)         <span class="ruby-comment">#=&gt; TypeError</span>
<span class="ruby-constant">Rational</span>(<span class="ruby-value">1</span>, <span class="ruby-keyword">nil</span>)      <span class="ruby-comment">#=&gt; TypeError</span>

<span class="ruby-constant">Rational</span>(<span class="ruby-string">&quot;10 cents&quot;</span>, <span class="ruby-value">exception:</span> <span class="ruby-keyword">false</span>)  <span class="ruby-comment">#=&gt; nil</span>
</pre>

<p>Syntax of the string form:</p>

<pre>string form = extra spaces , rational , extra spaces ;
rational = [ sign ] , unsigned rational ;
unsigned rational = numerator | numerator , &quot;/&quot; , denominator ;
numerator = integer part | fractional part | integer part , fractional part ;
denominator = digits ;
integer part = digits ;
fractional part = &quot;.&quot; , digits , [ ( &quot;e&quot; | &quot;E&quot; ) , [ sign ] , digits ] ;
sign = &quot;-&quot; | &quot;+&quot; ;
digits = digit , { digit | &quot;_&quot; , digit } ;
digit = &quot;0&quot; | &quot;1&quot; | &quot;2&quot; | &quot;3&quot; | &quot;4&quot; | &quot;5&quot; | &quot;6&quot; | &quot;7&quot; | &quot;8&quot; | &quot;9&quot; ;
extra spaces = ? \s* ? ;</pre>

<p>See also <a href="String.html#method-i-to_r"><code>String#to_r</code></a>.</p>

                              <div class="method-source-code" id="Rational-source">
            <pre>static VALUE
nurat_f_rational(int argc, VALUE *argv, VALUE klass)
{
    VALUE a1, a2, opts = Qnil;
    int raise = TRUE;

    if (rb_scan_args(argc, argv, &quot;11:&quot;, &amp;a1, &amp;a2, &amp;opts) == 1) {
        a2 = Qundef;
    }
    if (!NIL_P(opts)) {
        raise = rb_opts_exception_p(opts, raise);
    }
    return nurat_convert(rb_cRational, a1, a2, raise);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-String" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          String(object) &rarr; object or new_string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string converted from <code>object</code>.</p>

<p>Tries to convert <code>object</code> to a string using <code>to_str</code> first and <code>to_s</code> second:</p>

<pre class="ruby"><span class="ruby-constant">String</span>([<span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">2</span>])        <span class="ruby-comment"># =&gt; &quot;[0, 1, 2]&quot;</span>
<span class="ruby-constant">String</span>(<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">5</span>)             <span class="ruby-comment"># =&gt; &quot;0..5&quot;</span>
<span class="ruby-constant">String</span>({<span class="ruby-value">foo:</span> <span class="ruby-value">0</span>, <span class="ruby-value">bar:</span> <span class="ruby-value">1</span>}) <span class="ruby-comment"># =&gt; &quot;{:foo=&gt;0, :bar=&gt;1}&quot;</span>
</pre>

<p>Raises <code>TypeError</code> if <code>object</code> cannot be converted to a string.</p>

                              <div class="method-source-code" id="String-source">
            <pre>static VALUE
rb_f_string(VALUE obj, VALUE arg)
{
    return rb_String(arg);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-__callee__" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          __callee__         &rarr; symbol
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the called name of the current method as a <a href="Symbol.html"><code>Symbol</code></a>. If called outside of a method, it returns <code>nil</code>.</p>

                              <div class="method-source-code" id="__callee__-source">
            <pre>static VALUE
rb_f_callee_name(VALUE _)
{
    ID fname = prev_frame_callee(); /* need *callee* ID */

    if (fname) {
        return ID2SYM(fname);
    }
    else {
        return Qnil;
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-__dir__" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          __dir__         &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the canonicalized absolute path of the directory of the file from which this method is called. It means symlinks in the path is resolved. If <code>__FILE__</code> is <code>nil</code>, it returns <code>nil</code>. The return value equals to <code>File.dirname(File.realpath(__FILE__))</code>.</p>

                              <div class="method-source-code" id="__dir__-source">
            <pre>static VALUE
f_current_dirname(VALUE _)
{
    VALUE base = rb_current_realfilepath();
    if (NIL_P(base)) {
        return Qnil;
    }
    base = rb_file_dirname(base);
    return base;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-__method__" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          __method__         &rarr; symbol
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the name at the definition of the current method as a <a href="Symbol.html"><code>Symbol</code></a>. If called outside of a method, it returns <code>nil</code>.</p>

                              <div class="method-source-code" id="__method__-source">
            <pre>static VALUE
rb_f_method_name(VALUE _)
{
    ID fname = prev_frame_func(); /* need *method* ID */

    if (fname) {
        return ID2SYM(fname);
    }
    else {
        return Qnil;
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-60" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          `command` &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the <code>$stdout</code> output from running <code>command</code> in a subshell; sets global variable <code>$?</code> to the process status.</p>

<p>This method has potential security vulnerabilities if called with untrusted input; see <a href="command_injection_rdoc.html">Command Injection</a>.</p>

<p>Examples:</p>

<pre>$ `date`                 # =&gt; &quot;Wed Apr  9 08:56:30 CDT 2003\n&quot;
$ `echo oops &amp;&amp; exit 99` # =&gt; &quot;oops\n&quot;
$ $?                     # =&gt; #&lt;Process::Status: pid 17088 exit 99&gt;
$ $?.status              # =&gt; 99&gt;</pre>

<p>The built-in syntax <code>%x{...}</code> uses this method.</p>

                              <div class="method-source-code" id="60-source">
            <pre>static VALUE
rb_f_backquote(VALUE obj, VALUE str)
{
    VALUE port;
    VALUE result;
    rb_io_t *fptr;

    SafeStringValue(str);
    rb_last_status_clear();
    port = pipe_open_s(str, &quot;r&quot;, FMODE_READABLE|DEFAULT_TEXTMODE, NULL);
    if (NIL_P(port)) return rb_str_new(0,0);

    GetOpenFile(port, fptr);
    rb_obj_hide(port);
    result = read_all(fptr, remain_size(fptr), Qnil);
    rb_io_close(port);
    RFILE(port)-&gt;fptr = NULL;
    rb_io_fptr_finalize(fptr);
    RB_GC_GUARD(port);

    return result;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-abort" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          abort
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          abort(msg = nil)
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Terminates execution immediately, effectively by calling <code>Kernel.exit(false)</code>.</p>

<p>If string argument <code>msg</code> is given, it is written to STDERR prior to termination; otherwise, if an exception was raised, prints its message and backtrace.</p>

                              <div class="method-source-code" id="abort-source">
            <pre>static VALUE
f_abort(int c, const VALUE *a, VALUE _)
{
    rb_f_abort(c, a);
    UNREACHABLE_RETURN(Qnil);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-at_exit" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          at_exit { block } &rarr; proc
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Converts <em>block</em> to a <code>Proc</code> object (and therefore binds it at the point of call) and registers it for execution when the program exits. If multiple handlers are registered, they are executed in reverse order of registration.</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">do_at_exit</span>(<span class="ruby-identifier">str1</span>)
  <span class="ruby-identifier">at_exit</span> { <span class="ruby-identifier">print</span> <span class="ruby-identifier">str1</span> }
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">at_exit</span> { <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;cruel world&quot;</span> }
<span class="ruby-identifier">do_at_exit</span>(<span class="ruby-string">&quot;goodbye &quot;</span>)
<span class="ruby-identifier">exit</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-identifier">goodbye</span> <span class="ruby-identifier">cruel</span> <span class="ruby-identifier">world</span>
</pre>

                              <div class="method-source-code" id="at_exit-source">
            <pre>static VALUE
rb_f_at_exit(VALUE _)
{
    VALUE proc;

    if (!rb_block_given_p()) {
        rb_raise(rb_eArgError, &quot;called without a block&quot;);
    }
    proc = rb_block_proc();
    rb_set_end_proc(rb_call_end_proc, proc);
    return proc;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-autoload" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          autoload(const, filename)   &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <pre>Registers _filename_ to be loaded (using Kernel::require)
the first time that _const_ (which may be a String or
a symbol) is accessed.

   autoload(:MyModule, &quot;/usr/local/lib/modules/my_module.rb&quot;)</pre>

<p>If <em>const</em> is defined as autoload, the file name to be loaded is replaced with <em>filename</em>.  If <em>const</em> is defined but not as autoload, does nothing.</p>

                              <div class="method-source-code" id="autoload-source">
            <pre>static VALUE
rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
{
    VALUE klass = rb_class_real(rb_vm_cbase());
    if (!klass) {
        rb_raise(rb_eTypeError, &quot;Can not set autoload on singleton class&quot;);
    }
    return rb_mod_autoload(klass, sym, file);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-autoload-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          autoload?(name, inherit=true)   &rarr; String or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <em>filename</em> to be loaded if <em>name</em> is registered as <code>autoload</code>.</p>

<pre class="ruby"><span class="ruby-identifier">autoload</span>(<span class="ruby-value">:B</span>, <span class="ruby-string">&quot;b&quot;</span>)
<span class="ruby-identifier">autoload?</span>(<span class="ruby-value">:B</span>)            <span class="ruby-comment">#=&gt; &quot;b&quot;</span>
</pre>

                              <div class="method-source-code" id="autoload-3F-source">
            <pre>static VALUE
rb_f_autoload_p(int argc, VALUE *argv, VALUE obj)
{
    /* use rb_vm_cbase() as same as rb_f_autoload. */
    VALUE klass = rb_vm_cbase();
    if (NIL_P(klass)) {
        return Qnil;
    }
    return rb_mod_autoload_p(argc, argv, klass);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-binding" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          binding &rarr; a_binding
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a <a href="Binding.html"><code>Binding</code></a> object, describing the variable and method bindings at the point of call. This object can be used when calling <a href="Binding.html#method-i-eval"><code>Binding#eval</code></a> to execute the evaluated command in this environment, or extracting its local variables.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">User</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">position</span>)
    <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
    <span class="ruby-ivar">@position</span> = <span class="ruby-identifier">position</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_binding</span>
    <span class="ruby-identifier">binding</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;Joan&#39;</span>, <span class="ruby-string">&#39;manager&#39;</span>)
<span class="ruby-identifier">template</span> = <span class="ruby-string">&#39;{name: @name, position: @position}&#39;</span>

<span class="ruby-comment"># evaluate template in context of the object</span>
<span class="ruby-identifier">eval</span>(<span class="ruby-identifier">template</span>, <span class="ruby-identifier">user</span>.<span class="ruby-identifier">get_binding</span>)
<span class="ruby-comment">#=&gt; {:name=&gt;&quot;Joan&quot;, :position=&gt;&quot;manager&quot;}</span>
</pre>

<p><a href="Binding.html#method-i-local_variable_get"><code>Binding#local_variable_get</code></a> can be used to access the variables whose names are reserved Ruby keywords:</p>

<pre class="ruby"><span class="ruby-comment"># This is valid parameter declaration, but `if` parameter can&#39;t</span>
<span class="ruby-comment"># be accessed by name, because it is a reserved word.</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">validate</span>(<span class="ruby-identifier">field</span>, <span class="ruby-identifier">validation</span>, <span class="ruby-value">if:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">condition</span> = <span class="ruby-identifier">binding</span>.<span class="ruby-identifier">local_variable_get</span>(<span class="ruby-string">&#39;if&#39;</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">condition</span>

  <span class="ruby-comment"># ...Some implementation ...</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">validate</span>(<span class="ruby-value">:name</span>, <span class="ruby-value">:empty?</span>, <span class="ruby-value">if:</span> <span class="ruby-keyword">false</span>) <span class="ruby-comment"># skips validation</span>
<span class="ruby-identifier">validate</span>(<span class="ruby-value">:name</span>, <span class="ruby-value">:empty?</span>, <span class="ruby-value">if:</span> <span class="ruby-keyword">true</span>) <span class="ruby-comment"># performs validation</span>
</pre>

                              <div class="method-source-code" id="binding-source">
            <pre>static VALUE
rb_f_binding(VALUE self)
{
    return rb_binding_new();
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-block_given-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          block_given?   &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>yield</code> would execute a block in the current context. The <code>iterator?</code> form is mildly deprecated.</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">try</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
    <span class="ruby-keyword">yield</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-string">&quot;no block&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">try</span>                  <span class="ruby-comment">#=&gt; &quot;no block&quot;</span>
<span class="ruby-identifier">try</span> { <span class="ruby-string">&quot;hello&quot;</span> }      <span class="ruby-comment">#=&gt; &quot;hello&quot;</span>
<span class="ruby-identifier">try</span> <span class="ruby-keyword">do</span> <span class="ruby-string">&quot;hello&quot;</span> <span class="ruby-keyword">end</span>   <span class="ruby-comment">#=&gt; &quot;hello&quot;</span>
</pre>

                              <div class="method-source-code" id="block_given-3F-source">
            <pre>static VALUE
rb_f_block_given_p(VALUE _)
{
    rb_execution_context_t *ec = GET_EC();
    rb_control_frame_t *cfp = ec-&gt;cfp;
    cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));

    return RBOOL(cfp != NULL &amp;&amp; VM_CF_BLOCK_HANDLER(cfp) != VM_BLOCK_HANDLER_NONE);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-callcc" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          callcc {|cont| block }   &rarr;  obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Generates a <a href="Continuation.html"><code>Continuation</code></a> object, which it passes to the associated block. You need to <code>require &#39;continuation&#39;</code> before using this method. Performing a <em>cont</em><code>.call</code> will cause the <a href="Kernel.html#method-i-callcc"><code>callcc</code></a> to return (as will falling through the end of the block). The value returned by the <a href="Kernel.html#method-i-callcc"><code>callcc</code></a> is the value of the block, or the value passed to <em>cont</em><code>.call</code>. See class <a href="Continuation.html"><code>Continuation</code></a> for more details. Also see <a href="Kernel.html#method-i-throw"><code>Kernel#throw</code></a> for an alternative mechanism for unwinding a call stack.</p>

                              <div class="method-source-code" id="callcc-source">
            <pre>static VALUE
rb_callcc(VALUE self)
{
    volatile int called;
    volatile VALUE val = cont_capture(&amp;called);

    if (called) {
        return val;
    }
    else {
        return rb_yield(val);
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-caller" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          caller(start=1, length=nil)  &rarr; array or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          caller(range)                &rarr; array or nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns the current execution stack—an array containing strings in the form <code>file:line</code> or <code>file:line: in `method&#39;</code>.</p>

<p>The optional <em>start</em> parameter determines the number of initial stack entries to omit from the top of the stack.</p>

<p>A second optional <code>length</code> parameter can be used to limit how many entries are returned from the stack.</p>

<p>Returns <code>nil</code> if <em>start</em> is greater than the size of current execution stack.</p>

<p>Optionally you can pass a range, which will return an array containing the entries within the specified range.</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">a</span>(<span class="ruby-identifier">skip</span>)
  <span class="ruby-identifier">caller</span>(<span class="ruby-identifier">skip</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">b</span>(<span class="ruby-identifier">skip</span>)
  <span class="ruby-identifier">a</span>(<span class="ruby-identifier">skip</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">c</span>(<span class="ruby-identifier">skip</span>)
  <span class="ruby-identifier">b</span>(<span class="ruby-identifier">skip</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">c</span>(<span class="ruby-value">0</span>)   <span class="ruby-comment">#=&gt; [&quot;prog:2:in `a&#39;&quot;, &quot;prog:5:in `b&#39;&quot;, &quot;prog:8:in `c&#39;&quot;, &quot;prog:10:in `&lt;main&gt;&#39;&quot;]</span>
<span class="ruby-identifier">c</span>(<span class="ruby-value">1</span>)   <span class="ruby-comment">#=&gt; [&quot;prog:5:in `b&#39;&quot;, &quot;prog:8:in `c&#39;&quot;, &quot;prog:11:in `&lt;main&gt;&#39;&quot;]</span>
<span class="ruby-identifier">c</span>(<span class="ruby-value">2</span>)   <span class="ruby-comment">#=&gt; [&quot;prog:8:in `c&#39;&quot;, &quot;prog:12:in `&lt;main&gt;&#39;&quot;]</span>
<span class="ruby-identifier">c</span>(<span class="ruby-value">3</span>)   <span class="ruby-comment">#=&gt; [&quot;prog:13:in `&lt;main&gt;&#39;&quot;]</span>
<span class="ruby-identifier">c</span>(<span class="ruby-value">4</span>)   <span class="ruby-comment">#=&gt; []</span>
<span class="ruby-identifier">c</span>(<span class="ruby-value">5</span>)   <span class="ruby-comment">#=&gt; nil</span>
</pre>

                              <div class="method-source-code" id="caller-source">
            <pre>static VALUE
rb_f_caller(int argc, VALUE *argv, VALUE _)
{
    return ec_backtrace_to_ary(GET_EC(), argc, argv, 1, 1, 1);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-caller_locations" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          caller_locations(start=1, length=nil)    &rarr; array or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          caller_locations(range)                  &rarr; array or nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns the current execution stack—an array containing backtrace location objects.</p>

<p>See <a href="Thread/Backtrace/Location.html"><code>Thread::Backtrace::Location</code></a> for more information.</p>

<p>The optional <em>start</em> parameter determines the number of initial stack entries to omit from the top of the stack.</p>

<p>A second optional <code>length</code> parameter can be used to limit how many entries are returned from the stack.</p>

<p>Returns <code>nil</code> if <em>start</em> is greater than the size of current execution stack.</p>

<p>Optionally you can pass a range, which will return an array containing the entries within the specified range.</p>

                              <div class="method-source-code" id="caller_locations-source">
            <pre>static VALUE
rb_f_caller_locations(int argc, VALUE *argv, VALUE _)
{
    return ec_backtrace_to_ary(GET_EC(), argc, argv, 1, 1, 0);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-catch" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          catch([tag]) {|tag| block }  &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p><code>catch</code> executes its block. If <code>throw</code> is not called, the block executes normally, and <code>catch</code> returns the value of the last expression evaluated.</p>

<pre class="ruby"><span class="ruby-identifier">catch</span>(<span class="ruby-value">1</span>) { <span class="ruby-value">123</span> }            <span class="ruby-comment"># =&gt; 123</span>
</pre>

<p>If <code>throw(tag2, val)</code> is called, Ruby searches up its stack for a <code>catch</code> block whose <code>tag</code> has the same <code>object_id</code> as <em>tag2</em>. When found, the block stops executing and returns <em>val</em> (or <code>nil</code> if no second argument was given to <code>throw</code>).</p>

<pre class="ruby"><span class="ruby-identifier">catch</span>(<span class="ruby-value">1</span>) { <span class="ruby-identifier">throw</span>(<span class="ruby-value">1</span>, <span class="ruby-value">456</span>) }  <span class="ruby-comment"># =&gt; 456</span>
<span class="ruby-identifier">catch</span>(<span class="ruby-value">1</span>) { <span class="ruby-identifier">throw</span>(<span class="ruby-value">1</span>) }       <span class="ruby-comment"># =&gt; nil</span>
</pre>

<p>When <code>tag</code> is passed as the first argument, <code>catch</code> yields it as the parameter of the block.</p>

<pre class="ruby"><span class="ruby-identifier">catch</span>(<span class="ruby-value">1</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span> }       <span class="ruby-comment"># =&gt; 3</span>
</pre>

<p>When no <code>tag</code> is given, <code>catch</code> yields a new unique object (as from <code>Object.new</code>) as the block parameter. This object can then be used as the argument to <code>throw</code>, and will match the correct <code>catch</code> block.</p>

<pre class="ruby"><span class="ruby-identifier">catch</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj_A</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">catch</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj_B</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">throw</span>(<span class="ruby-identifier">obj_B</span>, <span class="ruby-value">123</span>)
    <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;This puts is not reached&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;This puts is displayed&quot;</span>
  <span class="ruby-value">456</span>
<span class="ruby-keyword">end</span>

<span class="ruby-comment"># =&gt; 456</span>

<span class="ruby-identifier">catch</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj_A</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">catch</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj_B</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">throw</span>(<span class="ruby-identifier">obj_A</span>, <span class="ruby-value">123</span>)
    <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;This puts is still not reached&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;Now this puts is also not reached&quot;</span>
  <span class="ruby-value">456</span>
<span class="ruby-keyword">end</span>

<span class="ruby-comment"># =&gt; 123</span>
</pre>

                              <div class="method-source-code" id="catch-source">
            <pre>static VALUE
rb_f_catch(int argc, VALUE *argv, VALUE self)
{
    VALUE tag = rb_check_arity(argc, 0, 1) ? argv[0] : rb_obj_alloc(rb_cObject);
    return rb_catch_obj(tag, catch_i, 0);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-chomp" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          chomp            &rarr; $_
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          chomp(string)    &rarr; $_
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to <code>$_ = $_.chomp(<em>string</em>)</code>. See <a href="String.html#method-i-chomp"><code>String#chomp</code></a>. Available only when -p/-n command line option specified.</p>

                              <div class="method-source-code" id="chomp-source">
            <pre>static VALUE
rb_f_chomp(int argc, VALUE *argv, VALUE _)
{
    VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern(&quot;chomp&quot;), argc, argv);
    rb_lastline_set(str);
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-chop" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          chop   &rarr; $_
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to <code>($_.dup).chop!</code>, except <code>nil</code> is never returned. See <a href="String.html#method-i-chop-21"><code>String#chop!</code></a>. Available only when -p/-n command line option specified.</p>

                              <div class="method-source-code" id="chop-source">
            <pre>static VALUE
rb_f_chop(VALUE _)
{
    VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern(&quot;chop&quot;), 0, 0);
    rb_lastline_set(str);
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-class" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          class    &rarr; class
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the class of <em>obj</em>. This method must always be called with an explicit receiver, as <a href="Kernel.html#method-i-class"><code>class</code></a> is also a reserved word in Ruby.</p>

<pre class="ruby"><span class="ruby-value">1</span>.<span class="ruby-identifier">class</span>      <span class="ruby-comment">#=&gt; Integer</span>
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>   <span class="ruby-comment">#=&gt; Object</span>
</pre>

                              <div class="method-source-code" id="class-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/kernel.rb, line 18</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">class</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier ruby-title">attr!</span> <span class="ruby-value">:leaf</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">&#39;rb_obj_class(self)&#39;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-clone" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          clone(freeze: nil) &rarr; an_object
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Produces a shallow copy of <em>obj</em>—the instance variables of <em>obj</em> are copied, but not the objects they reference. <a href="Kernel.html#method-i-clone"><code>clone</code></a> copies the frozen value state of <em>obj</em>, unless the <code>:freeze</code> keyword argument is given with a false or true value. See also the discussion under <a href="Object.html#method-i-dup"><code>Object#dup</code></a>.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Klass</span>
   <span class="ruby-identifier">attr_accessor</span> <span class="ruby-value">:str</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">s1</span> = <span class="ruby-constant">Klass</span>.<span class="ruby-identifier">new</span>      <span class="ruby-comment">#=&gt; #&lt;Klass:0x401b3a38&gt;</span>
<span class="ruby-identifier">s1</span>.<span class="ruby-identifier">str</span> = <span class="ruby-string">&quot;Hello&quot;</span>    <span class="ruby-comment">#=&gt; &quot;Hello&quot;</span>
<span class="ruby-identifier">s2</span> = <span class="ruby-identifier">s1</span>.<span class="ruby-identifier">clone</span>       <span class="ruby-comment">#=&gt; #&lt;Klass:0x401b3998 @str=&quot;Hello&quot;&gt;</span>
<span class="ruby-identifier">s2</span>.<span class="ruby-identifier">str</span>[<span class="ruby-value">1</span>,<span class="ruby-value">4</span>] = <span class="ruby-string">&quot;i&quot;</span>   <span class="ruby-comment">#=&gt; &quot;i&quot;</span>
<span class="ruby-identifier">s1</span>.<span class="ruby-identifier">inspect</span>          <span class="ruby-comment">#=&gt; &quot;#&lt;Klass:0x401b3a38 @str=\&quot;Hi\&quot;&gt;&quot;</span>
<span class="ruby-identifier">s2</span>.<span class="ruby-identifier">inspect</span>          <span class="ruby-comment">#=&gt; &quot;#&lt;Klass:0x401b3998 @str=\&quot;Hi\&quot;&gt;&quot;</span>
</pre>

<p>This method may have class-specific behavior.  If so, that behavior will be documented under the #<code>initialize_copy</code> method of the class.</p>

                              <div class="method-source-code" id="clone-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/kernel.rb, line 47</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">clone</span>(<span class="ruby-value">freeze:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_obj_clone2</span>(<span class="ruby-identifier">freeze</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-eval" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          eval(string [, binding [, filename [,lineno]]])  &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Evaluates the Ruby expression(s) in <em>string</em>. If <em>binding</em> is given, which must be a <a href="Binding.html"><code>Binding</code></a> object, the evaluation is performed in its context. If the optional <em>filename</em> and <em>lineno</em> parameters are present, they will be used when reporting syntax errors.</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_binding</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">binding</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">str</span> = <span class="ruby-string">&quot;hello&quot;</span>
<span class="ruby-identifier">eval</span> <span class="ruby-string">&quot;str + &#39; Fred&#39;&quot;</span>                      <span class="ruby-comment">#=&gt; &quot;hello Fred&quot;</span>
<span class="ruby-identifier">eval</span> <span class="ruby-string">&quot;str + &#39; Fred&#39;&quot;</span>, <span class="ruby-identifier">get_binding</span>(<span class="ruby-string">&quot;bye&quot;</span>)  <span class="ruby-comment">#=&gt; &quot;bye Fred&quot;</span>
</pre>

                              <div class="method-source-code" id="eval-source">
            <pre>VALUE
rb_f_eval(int argc, const VALUE *argv, VALUE self)
{
    VALUE src, scope, vfile, vline;
    VALUE file = Qundef;
    int line = 1;

    rb_scan_args(argc, argv, &quot;13&quot;, &amp;src, &amp;scope, &amp;vfile, &amp;vline);
    SafeStringValue(src);
    if (argc &gt;= 3) {
        StringValue(vfile);
    }
    if (argc &gt;= 4) {
        line = NUM2INT(vline);
    }

    if (!NIL_P(vfile))
        file = vfile;

    if (NIL_P(scope))
        return eval_string_with_cref(self, src, NULL, file, line);
    else
        return eval_string_with_scope(scope, src, file, line);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-exec" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          exec([env, ] command_line, options = {})
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          exec([env, ] exe_path, *args, options  = {})
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Replaces the current process by doing one of the following:</p>
<ul><li>
<p>Passing string <code>command_line</code> to the shell.</p>
</li><li>
<p>Invoking the executable at <code>exe_path</code>.</p>
</li></ul>

<p>This method has potential security vulnerabilities if called with untrusted input; see <a href="command_injection_rdoc.html">Command Injection</a>.</p>

<p>The new process is created using the <a href="https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/execve.html">exec system call</a>; it may inherit some of its environment from the calling program (possibly including open file descriptors).</p>

<p>Argument <code>env</code>, if given, is a hash that affects <code>ENV</code> for the new process; see <a href="Process.html#module-Process-label-Execution+Environment">Execution Environment</a>.</p>

<p>Argument <code>options</code> is a hash of options for the new process; see <a href="Process.html#module-Process-label-Execution+Options">Execution Options</a>.</p>

<p>The first required argument is one of the following:</p>
<ul><li>
<p><code>command_line</code> if it is a string, and if it begins with a shell reserved word or special built-in, or if it contains one or more metacharacters.</p>
</li><li>
<p><code>exe_path</code> otherwise.</p>
</li></ul>

<p><strong>Argument <code>command_line</code></strong></p>

<p>String argument <code>command_line</code> is a command line to be passed to a shell; it must begin with a shell reserved word, begin with a special built-in, or contain meta characters:</p>

<pre class="ruby"><span class="ruby-identifier">exec</span>(<span class="ruby-string">&#39;echo&#39;</span>)                         <span class="ruby-comment"># Built-in.</span>
<span class="ruby-identifier">exec</span>(<span class="ruby-string">&#39;if true; then echo &quot;Foo&quot;; fi&#39;</span>) <span class="ruby-comment"># Shell reserved word.</span>
<span class="ruby-identifier">exec</span>(<span class="ruby-string">&#39;date &gt; date.tmp&#39;</span>)              <span class="ruby-comment"># Contains meta character.</span>
</pre>

<p>The command line may also contain arguments and options for the command:</p>

<pre class="ruby"><span class="ruby-identifier">exec</span>(<span class="ruby-string">&#39;echo &quot;Foo&quot;&#39;</span>)
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-constant">Foo</span>
</pre>

<p>On a Unix-like system, the shell is <code>/bin/sh</code>; otherwise the shell is determined by environment variable <code>ENV[&#39;RUBYSHELL&#39;]</code>, if defined, or <code>ENV[&#39;COMSPEC&#39;]</code> otherwise.</p>

<p>Except for the <code>COMSPEC</code> case, the entire string <code>command_line</code> is passed as an argument to <a href="https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/sh.html">shell option -c</a>.</p>

<p>The shell performs normal shell expansion on the command line:</p>

<pre class="ruby"><span class="ruby-identifier">exec</span>(<span class="ruby-string">&#39;echo C*&#39;</span>)
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-constant">CONTRIBUTING</span>.<span class="ruby-identifier">md</span> <span class="ruby-constant">COPYING</span> <span class="ruby-constant">COPYING</span>.<span class="ruby-identifier">ja</span>
</pre>

<p>Raises an exception if the new process could not execute.</p>

<p><strong>Argument <code>exe_path</code></strong></p>

<p>Argument <code>exe_path</code> is one of the following:</p>
<ul><li>
<p>The string path to an executable to be called.</p>
</li><li>
<p>A 2-element array containing the path to an executable and the string to be used as the name of the executing process.</p>
</li></ul>

<p>Example:</p>

<pre class="ruby"><span class="ruby-identifier">exec</span>(<span class="ruby-string">&#39;/usr/bin/date&#39;</span>)
</pre>

<p>Output:</p>

<pre>Sat Aug 26 09:38:00 AM CDT 2023</pre>

<p>Ruby invokes the executable directly, with no shell and no shell expansion:</p>

<pre class="ruby"><span class="ruby-identifier">exec</span>(<span class="ruby-string">&#39;doesnt_exist&#39;</span>) <span class="ruby-comment"># Raises Errno::ENOENT</span>
</pre>

<p>If one or more <code>args</code> is given, each is an argument or option to be passed to the executable:</p>

<pre class="ruby"><span class="ruby-identifier">exec</span>(<span class="ruby-string">&#39;echo&#39;</span>, <span class="ruby-string">&#39;C*&#39;</span>)
<span class="ruby-identifier">exec</span>(<span class="ruby-string">&#39;echo&#39;</span>, <span class="ruby-string">&#39;hello&#39;</span>, <span class="ruby-string">&#39;world&#39;</span>)
</pre>

<p>Output:</p>

<pre>C*
hello world</pre>

<p>Raises an exception if the new process could not execute.</p>

                              <div class="method-source-code" id="exec-source">
            <pre>static VALUE
f_exec(int c, const VALUE *a, VALUE _)
{
    rb_f_exec(c, a);
    UNREACHABLE_RETURN(Qnil);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-exit" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          exit(status = true)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          exit(status = true)
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Initiates termination of the Ruby script by raising <a href="SystemExit.html"><code>SystemExit</code></a>; the exception may be caught. Returns exit status <code>status</code> to the underlying operating system.</p>

<p>Values <code>true</code> and <code>false</code> for argument <code>status</code> indicate, respectively, success and failure; The meanings of integer values are system-dependent.</p>

<p>Example:</p>

<pre class="ruby"><span class="ruby-keyword">begin</span>
  <span class="ruby-identifier">exit</span>
  <span class="ruby-identifier">puts</span> <span class="ruby-string">&#39;Never get here.&#39;</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">SystemExit</span>
  <span class="ruby-identifier">puts</span> <span class="ruby-string">&#39;Rescued a SystemExit exception.&#39;</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">puts</span> <span class="ruby-string">&#39;After begin block.&#39;</span>
</pre>

<p>Output:</p>

<pre>Rescued a SystemExit exception.
After begin block.</pre>

<p>Just prior to final termination, Ruby executes any at-exit procedures (see Kernel::at_exit) and any object finalizers (see <a href="ObjectSpace.html#method-c-define_finalizer"><code>ObjectSpace::define_finalizer</code></a>).</p>

<p>Example:</p>

<pre class="ruby"><span class="ruby-identifier">at_exit</span> { <span class="ruby-identifier">puts</span> <span class="ruby-string">&#39;In at_exit function.&#39;</span> }
<span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-string">&#39;string&#39;</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">puts</span> <span class="ruby-string">&#39;In finalizer.&#39;</span> })
<span class="ruby-identifier">exit</span>
</pre>

<p>Output:</p>

<pre>In at_exit function.
In finalizer.</pre>

                              <div class="method-source-code" id="exit-source">
            <pre>static VALUE
f_exit(int c, const VALUE *a, VALUE _)
{
    rb_f_exit(c, a);
    UNREACHABLE_RETURN(Qnil);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-exit-21" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          exit!(status = false)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          exit!(status = false)
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Exits the process immediately; no exit handlers are called. Returns exit status <code>status</code> to the underlying operating system.</p>

<pre class="ruby"><span class="ruby-constant">Process</span>.<span class="ruby-identifier">exit!</span>(<span class="ruby-keyword">true</span>)
</pre>

<p>Values <code>true</code> and <code>false</code> for argument <code>status</code> indicate, respectively, success and failure; The meanings of integer values are system-dependent.</p>

                              <div class="method-source-code" id="exit-21-source">
            <pre>static VALUE
rb_f_exit_bang(int argc, VALUE *argv, VALUE obj)
{
    int istatus;

    if (rb_check_arity(argc, 0, 1) == 1) {
        istatus = exit_status_code(argv[0]);
    }
    else {
        istatus = EXIT_FAILURE;
    }
    _exit(istatus);

    UNREACHABLE_RETURN(Qnil);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fail" class="method-detail method-alias">
                      <div class="method-heading">
                        <span class="method-callseq">
                          fail
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          fail(string, cause: $!)
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          fail(exception [, string [, array]], cause: $!)
                              </span>
                            </div>

                            <div class="method-description">
                              <p>With no arguments, raises the exception in <code>$!</code> or raises a <a href="RuntimeError.html"><code>RuntimeError</code></a> if <code>$!</code> is <code>nil</code>.  With a single <code>String</code> argument, raises a <code>RuntimeError</code> with the string as a message. Otherwise, the first parameter should be an <code>Exception</code> class (or another object that returns an <code>Exception</code> object when sent an <code>exception</code> message).  The optional second parameter sets the message associated with the exception (accessible via <a href="Exception.html#method-i-message"><code>Exception#message</code></a>), and the third parameter is an array of callback information (accessible via <a href="Exception.html#method-i-backtrace"><code>Exception#backtrace</code></a>). The <code>cause</code> of the generated exception (accessible via <a href="Exception.html#method-i-cause"><code>Exception#cause</code></a>) is automatically set to the “current” exception (<code>$!</code>), if any. An alternative value, either an <code>Exception</code> object or <code>nil</code>, can be specified via the <code>:cause</code> argument.</p>

<p>Exceptions are caught by the <code>rescue</code> clause of <code>begin...end</code> blocks.</p>

<pre class="ruby"><span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;Failed to create socket&quot;</span>
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;No parameters&quot;</span>, <span class="ruby-identifier">caller</span>
</pre>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Kernel.html#method-i-raise">raise</a>
                            </div>
                          </div>

                  <div id="method-i-fork" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          fork { ... } &rarr; integer or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          fork &rarr; integer or nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates a child process.</p>

<p>With a block given, runs the block in the child process; on block exit, the child terminates with a status of zero:</p>

<pre class="ruby"><span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Before the fork: #{Process.pid}&quot;</span>
<span class="ruby-identifier">fork</span> <span class="ruby-keyword">do</span>
  <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;In the child process: #{Process.pid}&quot;</span>
<span class="ruby-keyword">end</span>                   <span class="ruby-comment"># =&gt; 382141</span>
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;After the fork: #{Process.pid}&quot;</span>
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-constant">Before</span> <span class="ruby-identifier">the</span> <span class="ruby-value">fork:</span> <span class="ruby-value">420496</span>
<span class="ruby-constant">After</span> <span class="ruby-identifier">the</span> <span class="ruby-value">fork:</span> <span class="ruby-value">420496</span>
<span class="ruby-constant">In</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">child</span> <span class="ruby-value">process:</span> <span class="ruby-value">420520</span>
</pre>

<p>With no block given, the <code>fork</code> call returns twice:</p>
<ul><li>
<p>Once in the parent process, returning the pid of the child process.</p>
</li><li>
<p>Once in the child process, returning <code>nil</code>.</p>
</li></ul>

<p>Example:</p>

<pre class="ruby"><span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;This is the first line before the fork (pid #{Process.pid})&quot;</span>
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">fork</span>
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;This is the second line after the fork (pid #{Process.pid})&quot;</span>
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-constant">This</span> <span class="ruby-identifier">is</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">first</span> <span class="ruby-identifier">line</span> <span class="ruby-identifier">before</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">fork</span> (<span class="ruby-identifier">pid</span> <span class="ruby-value">420199</span>)
<span class="ruby-value">420223</span>
<span class="ruby-constant">This</span> <span class="ruby-identifier">is</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">second</span> <span class="ruby-identifier">line</span> <span class="ruby-identifier">after</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">fork</span> (<span class="ruby-identifier">pid</span> <span class="ruby-value">420199</span>)

<span class="ruby-constant">This</span> <span class="ruby-identifier">is</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">second</span> <span class="ruby-identifier">line</span> <span class="ruby-identifier">after</span> <span class="ruby-identifier">the</span> <span class="ruby-identifier">fork</span> (<span class="ruby-identifier">pid</span> <span class="ruby-value">420223</span>)
</pre>

<p>In either case, the child process may exit using <a href="Kernel.html#method-i-exit-21"><code>Kernel.exit!</code></a> to avoid the call to <a href="Kernel.html#method-i-at_exit"><code>Kernel#at_exit</code></a>.</p>

<p>To avoid zombie processes, the parent process should call either:</p>
<ul><li>
<p><a href="Process.html#method-c-wait"><code>Process.wait</code></a>, to collect the termination statuses of its children.</p>
</li><li>
<p><a href="Process.html#method-c-detach"><code>Process.detach</code></a>, to register disinterest in their status.</p>
</li></ul>

<p>The thread calling <code>fork</code> is the only thread in the created child process; <code>fork</code> doesn’t copy other threads.</p>

<p>Note that method <code>fork</code> is available on some platforms, but not on others:</p>

<pre class="ruby"><span class="ruby-constant">Process</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:fork</span>) <span class="ruby-comment"># =&gt; true # Would be false on some.</span>
</pre>

<p>If not, you may use ::spawn instead of <code>fork</code>.</p>

                              <div class="method-source-code" id="fork-source">
            <pre>static VALUE
rb_f_fork(VALUE obj)
{
    rb_pid_t pid;

    pid = rb_call_proc__fork();

    if (pid == 0) {
        if (rb_block_given_p()) {
            int status;
            rb_protect(rb_yield, Qundef, &amp;status);
            ruby_stop(status);
        }
        return Qnil;
    }

    return PIDT2NUM(pid);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-format" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">format</span><span
                                class="method-args">(*args)</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the string resulting from formatting <code>objects</code> into <code>format_string</code>.</p>

<p>For details on <code>format_string</code>, see <a href="format_specifications_rdoc.html">Format Specifications</a>.</p>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Kernel.html#method-i-sprintf">sprintf</a>
                            </div>
                          </div>

                  <div id="method-i-frozen-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          frozen?    &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the freeze status of <em>obj</em>.</p>

<pre class="ruby"><span class="ruby-identifier">a</span> = [ <span class="ruby-string">&quot;a&quot;</span>, <span class="ruby-string">&quot;b&quot;</span>, <span class="ruby-string">&quot;c&quot;</span> ]
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">freeze</span>    <span class="ruby-comment">#=&gt; [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</span>
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">frozen?</span>   <span class="ruby-comment">#=&gt; true</span>
</pre>

                              <div class="method-source-code" id="frozen-3F-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/kernel.rb, line 67</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">frozen?</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">attr!</span> <span class="ruby-value">:leaf</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">&#39;rb_obj_frozen_p(self)&#39;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-gets" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          gets(sep=$/ [, getline_args])     &rarr; string or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          gets(limit [, getline_args])      &rarr; string or nil
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          gets(sep, limit [, getline_args]) &rarr; string or nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns (and assigns to <code>$_</code>) the next line from the list of files in <code>ARGV</code> (or <code>$*</code>), or from standard input if no files are present on the command line. Returns <code>nil</code> at end of file. The optional argument specifies the record separator. The separator is included with the contents of each record. A separator of <code>nil</code> reads the entire contents, and a zero-length separator reads the input one paragraph at a time, where paragraphs are divided by two consecutive newlines.  If the first argument is an integer, or optional second argument is given, the returning string would not be longer than the given value in bytes.  If multiple filenames are present in <code>ARGV</code>, <code>gets(nil)</code> will read the contents one file at a time.</p>

<pre class="ruby"><span class="ruby-constant">ARGV</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;testfile&quot;</span>
<span class="ruby-identifier">print</span> <span class="ruby-keyword">while</span> <span class="ruby-identifier">gets</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">This</span> <span class="ruby-identifier">is</span> <span class="ruby-identifier">line</span> <span class="ruby-identifier">one</span>
<span class="ruby-constant">This</span> <span class="ruby-identifier">is</span> <span class="ruby-identifier">line</span> <span class="ruby-identifier">two</span>
<span class="ruby-constant">This</span> <span class="ruby-identifier">is</span> <span class="ruby-identifier">line</span> <span class="ruby-identifier">three</span>
<span class="ruby-constant">And</span> <span class="ruby-identifier">so</span> <span class="ruby-identifier">on</span><span class="ruby-operator">...</span>
</pre>

<p>The style of programming using <code>$_</code> as an implicit parameter is gradually losing favor in the Ruby community.</p>

                              <div class="method-source-code" id="gets-source">
            <pre>static VALUE
rb_f_gets(int argc, VALUE *argv, VALUE recv)
{
    if (recv == argf) {
        return argf_gets(argc, argv, argf);
    }
    return forward(argf, idGets, argc, argv);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-global_variables" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          global_variables    &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of the names of global variables. This includes special regexp global variables such as <code>$~</code> and <code>$+</code>, but does not include the numbered regexp global variables (<code>$1</code>, <code>$2</code>, etc.).</p>

<pre class="ruby"><span class="ruby-identifier">global_variables</span>.<span class="ruby-identifier">grep</span> <span class="ruby-regexp">/std/</span>   <span class="ruby-comment">#=&gt; [:$stdin, :$stdout, :$stderr]</span>
</pre>

                              <div class="method-source-code" id="global_variables-source">
            <pre>static VALUE
f_global_variables(VALUE _)
{
    return rb_f_global_variables();
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-gsub" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          gsub(pattern, replacement)    &rarr; $_
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          gsub(pattern) {|...| block }  &rarr; $_
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to <code>$_.gsub...</code>, except that <code>$_</code> will be updated if substitution occurs. Available only when -p/-n command line option specified.</p>

                              <div class="method-source-code" id="gsub-source">
            <pre>static VALUE
rb_f_gsub(int argc, VALUE *argv, VALUE _)
{
    VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern(&quot;gsub&quot;), argc, argv);
    rb_lastline_set(str);
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-iterator-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          iterator?      &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Deprecated.  Use block_given? instead.</p>

                              <div class="method-source-code" id="iterator-3F-source">
            <pre>static VALUE
rb_f_iterator_p(VALUE self)
{
    rb_warn_deprecated(&quot;iterator?&quot;, &quot;block_given?&quot;);
    return rb_f_block_given_p(self);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-lambda" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          lambda { |...| block }  &rarr; a_proc
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to <a href="Proc.html#method-c-new"><code>Proc.new</code></a>, except the resulting <a href="Proc.html"><code>Proc</code></a> objects check the number of parameters passed when called.</p>

                              <div class="method-source-code" id="lambda-source">
            <pre>static VALUE
f_lambda(VALUE _)
{
    f_lambda_filter_non_literal();
    return rb_block_lambda();
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-load" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          load(filename, wrap=false)   &rarr; true
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Loads and executes the Ruby program in the file <em>filename</em>.</p>

<p>If the filename is an absolute path (e.g. starts with ‘/’), the file will be loaded directly using the absolute path.</p>

<p>If the filename is an explicit relative path (e.g. starts with ‘./’ or ‘../’), the file will be loaded using the relative path from the current directory.</p>

<p>Otherwise, the file will be searched for in the library directories listed in <code>$LOAD_PATH</code> (<code>$:</code>). If the file is found in a directory, it will attempt to load the file relative to that directory.  If the file is not found in any of the directories in <code>$LOAD_PATH</code>, the file will be loaded using the relative path from the current directory.</p>

<p>If the file doesn’t exist when there is an attempt to load it, a <a href="LoadError.html"><code>LoadError</code></a> will be raised.</p>

<p>If the optional <em>wrap</em> parameter is <code>true</code>, the loaded script will be executed under an anonymous module, protecting the calling program’s global namespace.  If the optional <em>wrap</em> parameter is a module, the loaded script will be executed under the given module. In no circumstance will any local variables in the loaded file be propagated to the loading environment.</p>

                              <div class="method-source-code" id="load-source">
            <pre>static VALUE
rb_f_load(int argc, VALUE *argv, VALUE _)
{
    VALUE fname, wrap, path, orig_fname;

    rb_scan_args(argc, argv, &quot;11&quot;, &amp;fname, &amp;wrap);

    orig_fname = rb_get_path_check_to_string(fname);
    fname = rb_str_encode_ospath(orig_fname);
    RUBY_DTRACE_HOOK(LOAD_ENTRY, RSTRING_PTR(orig_fname));

    path = rb_find_file(fname);
    if (!path) {
        if (!rb_file_load_ok(RSTRING_PTR(fname)))
            load_failed(orig_fname);
        path = fname;
    }
    rb_load_internal(path, wrap);

    RUBY_DTRACE_HOOK(LOAD_RETURN, RSTRING_PTR(orig_fname));

    return Qtrue;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-local_variables" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          local_variables    &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the names of the current local variables.</p>

<pre class="ruby"><span class="ruby-identifier">fred</span> = <span class="ruby-value">1</span>
<span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> <span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">10</span>
   <span class="ruby-comment"># ...</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">local_variables</span>   <span class="ruby-comment">#=&gt; [:fred, :i]</span>
</pre>

                              <div class="method-source-code" id="local_variables-source">
            <pre>static VALUE
rb_f_local_variables(VALUE _)
{
    struct local_var_list vars;
    rb_execution_context_t *ec = GET_EC();
    rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(ec-&gt;cfp));
    unsigned int i;

    local_var_list_init(&amp;vars);
    while (cfp) {
        if (cfp-&gt;iseq) {
            for (i = 0; i &lt; ISEQ_BODY(cfp-&gt;iseq)-&gt;local_table_size; i++) {
                local_var_list_add(&amp;vars, ISEQ_BODY(cfp-&gt;iseq)-&gt;local_table[i]);
            }
        }
        if (!VM_ENV_LOCAL_P(cfp-&gt;ep)) {
            /* block */
            const VALUE *ep = VM_CF_PREV_EP(cfp);

            if (vm_collect_local_variables_in_heap(ep, &amp;vars)) {
                break;
            }
            else {
                while (cfp-&gt;ep != ep) {
                    cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
                }
            }
        }
        else {
            break;
        }
    }
    return local_var_list_finish(&amp;vars);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-loop" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          loop { block }
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          loop            &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Repeatedly executes the block.</p>

<p>If no block is given, an enumerator is returned instead.</p>

<pre class="ruby"><span class="ruby-identifier">loop</span> <span class="ruby-keyword">do</span>
  <span class="ruby-identifier">print</span> <span class="ruby-string">&quot;Input: &quot;</span>
  <span class="ruby-identifier">line</span> = <span class="ruby-identifier">gets</span>
  <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">line</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^q/i</span>
  <span class="ruby-comment"># ...</span>
<span class="ruby-keyword">end</span>
</pre>

<p><a href="StopIteration.html"><code>StopIteration</code></a> raised in the block breaks the loop.  In this case, loop returns the “result” value stored in the exception.</p>

<pre class="ruby"><span class="ruby-identifier">enum</span> = <span class="ruby-constant">Enumerator</span>.<span class="ruby-identifier">new</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">y</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">y</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;one&quot;</span>
  <span class="ruby-identifier">y</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;two&quot;</span>
  <span class="ruby-value">:ok</span>
}

<span class="ruby-identifier">result</span> = <span class="ruby-identifier">loop</span> {
  <span class="ruby-identifier">puts</span> <span class="ruby-identifier">enum</span>.<span class="ruby-identifier">next</span>
} <span class="ruby-comment">#=&gt; :ok</span>
</pre>

                              <div class="method-source-code" id="loop-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/kernel.rb, line 180</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">loop</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">block_given?</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">enum_for</span>(<span class="ruby-value">:loop</span>) { <span class="ruby-constant">Float</span><span class="ruby-operator">::</span><span class="ruby-constant">INFINITY</span> }
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">while</span> <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">yield</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">StopIteration</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
    <span class="ruby-identifier">e</span>.<span class="ruby-identifier">result</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-open" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          open(path, mode = &#39;r&#39;, perm = 0666, **opts)             &rarr; io or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          open(path, mode = &#39;r&#39;, perm = 0666, **opts) {|io| ... } &rarr; obj
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates an <a href="IO.html"><code>IO</code></a> object connected to the given file.</p>

<p>This method has potential security vulnerabilities if called with untrusted input; see <a href="command_injection_rdoc.html">Command Injection</a>.</p>

<p>With no block given, file stream is returned:</p>

<pre class="ruby"><span class="ruby-identifier">open</span>(<span class="ruby-string">&#39;t.txt&#39;</span>) <span class="ruby-comment"># =&gt; #&lt;File:t.txt&gt;</span>
</pre>

<p>With a block given, calls the block with the open file stream, then closes the stream:</p>

<pre class="ruby"><span class="ruby-identifier">open</span>(<span class="ruby-string">&#39;t.txt&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span> <span class="ruby-identifier">f</span> } <span class="ruby-comment"># =&gt; #&lt;File:t.txt (closed)&gt;</span>
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-comment">#&lt;File:t.txt&gt;</span>
</pre>

<p>See <a href="File.html#method-c-open"><code>File.open</code></a> for details.</p>

                              <div class="method-source-code" id="open-source">
            <pre>static VALUE
rb_f_open(int argc, VALUE *argv, VALUE _)
{
    ID to_open = 0;
    int redirect = FALSE;

    if (argc &gt;= 1) {
        CONST_ID(to_open, &quot;to_open&quot;);
        if (rb_respond_to(argv[0], to_open)) {
            redirect = TRUE;
        }
        else {
            VALUE tmp = argv[0];
            FilePathValue(tmp);
            if (NIL_P(tmp)) {
                redirect = TRUE;
            }
            else {
                VALUE cmd = check_pipe_command(tmp);
                if (!NIL_P(cmd)) {
                    // TODO: when removed in 4.0, update command_injection.rdoc
                    rb_warn_deprecated_to_remove_at(4.0, &quot;Calling Kernel#open with a leading &#39;|&#39;&quot;, &quot;IO.popen&quot;);
                    argv[0] = cmd;
                    return rb_io_s_popen(argc, argv, rb_cIO);
                }
            }
        }
    }
    if (redirect) {
        VALUE io = rb_funcallv_kw(argv[0], to_open, argc-1, argv+1, RB_PASS_CALLED_KEYWORDS);

        if (rb_block_given_p()) {
            return rb_ensure(rb_yield, io, io_close, io);
        }
        return io;
    }
    return rb_io_s_open(argc, argv, rb_cFile);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-p" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          p(object)   &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          p(*objects) &rarr; array of objects
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          p           &rarr; nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>For each object <code>obj</code>, executes:</p>

<pre class="ruby"><span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">inspect</span>, <span class="ruby-string">&quot;\n&quot;</span>)
</pre>

<p>With one object given, returns the object; with multiple objects given, returns an array containing the objects; with no object given, returns <code>nil</code>.</p>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-identifier">r</span> = <span class="ruby-constant">Range</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>, <span class="ruby-value">4</span>)
<span class="ruby-identifier">p</span> <span class="ruby-identifier">r</span>                 <span class="ruby-comment"># =&gt; 0..4</span>
<span class="ruby-identifier">p</span> [<span class="ruby-identifier">r</span>, <span class="ruby-identifier">r</span>, <span class="ruby-identifier">r</span>]         <span class="ruby-comment"># =&gt; [0..4, 0..4, 0..4]</span>
<span class="ruby-identifier">p</span>                   <span class="ruby-comment"># =&gt; nil</span>
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">4</span>
[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">4</span>, <span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">4</span>, <span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">4</span>]
</pre>

<p><a href="Kernel.html#method-i-p"><code>Kernel#p</code></a> is designed for debugging purposes. Ruby implementations may define <a href="Kernel.html#method-i-p"><code>Kernel#p</code></a> to be uninterruptible in whole or in part. On CRuby, <a href="Kernel.html#method-i-p"><code>Kernel#p</code></a>‘s writing of data is uninterruptible.</p>

                              <div class="method-source-code" id="p-source">
            <pre>static VALUE
rb_f_p(int argc, VALUE *argv, VALUE self)
{
    int i;
    for (i=0; i&lt;argc; i++) {
        VALUE inspected = rb_obj_as_string(rb_inspect(argv[i]));
        rb_uninterruptible(rb_p_write, inspected);
    }
    return rb_p_result(argc, argv);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-print" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          print(*objects) &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to <code>$stdout.print(*objects)</code>, this method is the straightforward way to write to <code>$stdout</code>.</p>

<p>Writes the given objects to <code>$stdout</code>; returns <code>nil</code>. Appends the output record separator <code>$OUTPUT_RECORD_SEPARATOR</code> <code>$\</code>), if it is not <code>nil</code>.</p>

<p>With argument <code>objects</code> given, for each object:</p>
<ul><li>
<p>Converts via its method <code>to_s</code> if not a string.</p>
</li><li>
<p>Writes to <code>stdout</code>.</p>
</li><li>
<p>If not the last object, writes the output field separator <code>$OUTPUT_FIELD_SEPARATOR</code> (<code>$,</code> if it is not <code>nil</code>.</p>
</li></ul>

<p>With default separators:</p>

<pre class="ruby"><span class="ruby-identifier">objects</span> = [<span class="ruby-value">0</span>, <span class="ruby-value">0.0</span>, <span class="ruby-constant">Rational</span>(<span class="ruby-value">0</span>, <span class="ruby-value">1</span>), <span class="ruby-constant">Complex</span>(<span class="ruby-value">0</span>, <span class="ruby-value">0</span>), <span class="ruby-value">:zero</span>, <span class="ruby-string">&#39;zero&#39;</span>]
<span class="ruby-identifier">$OUTPUT_RECORD_SEPARATOR</span>
<span class="ruby-identifier">$OUTPUT_FIELD_SEPARATOR</span>
<span class="ruby-identifier">print</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">objects</span>)
</pre>

<p>Output:</p>

<pre>nil
nil
00.00/10+0izerozero</pre>

<p>With specified separators:</p>

<pre class="ruby"><span class="ruby-identifier">$OUTPUT_RECORD_SEPARATOR</span> = <span class="ruby-string">&quot;\n&quot;</span>
<span class="ruby-identifier">$OUTPUT_FIELD_SEPARATOR</span> = <span class="ruby-string">&#39;,&#39;</span>
<span class="ruby-identifier">print</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">objects</span>)
</pre>

<p>Output:</p>

<pre>0,0.0,0/1,0+0i,zero,zero</pre>

<p>With no argument given, writes the content of <code>$_</code> (which is usually the most recent user input):</p>

<pre class="ruby"><span class="ruby-identifier">gets</span>  <span class="ruby-comment"># Sets $_ to the most recent user input.</span>
<span class="ruby-identifier">print</span> <span class="ruby-comment"># Prints $_.</span>
</pre>

                              <div class="method-source-code" id="print-source">
            <pre>static VALUE
rb_f_print(int argc, const VALUE *argv, VALUE _)
{
    rb_io_print(argc, argv, rb_ractor_stdout());
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-printf" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          printf(format_string, *objects)               &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          printf(io, format_string, *objects) &rarr; nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to:</p>

<pre class="ruby"><span class="ruby-identifier">io</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">sprintf</span>(<span class="ruby-identifier">format_string</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">objects</span>))
</pre>

<p>For details on <code>format_string</code>, see <a href="format_specifications_rdoc.html">Format Specifications</a>.</p>

<p>With the single argument <code>format_string</code>, formats <code>objects</code> into the string, then writes the formatted string to $stdout:</p>

<pre class="ruby"><span class="ruby-identifier">printf</span>(<span class="ruby-string">&#39;%4.4d %10s %2.2f&#39;</span>, <span class="ruby-value">24</span>, <span class="ruby-value">24</span>, <span class="ruby-value">24.0</span>)
</pre>

<p>Output (on $stdout):</p>

<pre>0024         24 24.00#</pre>

<p>With arguments <code>io</code> and <code>format_string</code>, formats <code>objects</code> into the string, then writes the formatted string to <code>io</code>:</p>

<pre class="ruby"><span class="ruby-identifier">printf</span>(<span class="ruby-identifier">$stderr</span>, <span class="ruby-string">&#39;%4.4d %10s %2.2f&#39;</span>, <span class="ruby-value">24</span>, <span class="ruby-value">24</span>, <span class="ruby-value">24.0</span>)
</pre>

<p>Output (on $stderr):</p>

<pre>0024         24 24.00# =&gt; nil</pre>

<p>With no arguments, does nothing.</p>

                              <div class="method-source-code" id="printf-source">
            <pre>static VALUE
rb_f_printf(int argc, VALUE *argv, VALUE _)
{
    VALUE out;

    if (argc == 0) return Qnil;
    if (RB_TYPE_P(argv[0], T_STRING)) {
        out = rb_ractor_stdout();
    }
    else {
        out = argv[0];
        argv++;
        argc--;
    }
    rb_io_write(out, rb_f_sprintf(argc, argv));

    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-proc" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          proc   { |...| block }  &rarr; a_proc
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to <a href="Proc.html#method-c-new"><code>Proc.new</code></a>.</p>

                              <div class="method-source-code" id="proc-source">
            <pre>static VALUE
f_proc(VALUE _)
{
    return proc_new(rb_cProc, FALSE);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-putc" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          putc(int) &rarr; int
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to:</p>

<pre class="ruby"><span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">putc</span>(<span class="ruby-identifier">int</span>)
</pre>

<p>See <a href="IO.html#method-i-putc"><code>IO#putc</code></a> for important information regarding multi-byte characters.</p>

                              <div class="method-source-code" id="putc-source">
            <pre>static VALUE
rb_f_putc(VALUE recv, VALUE ch)
{
    VALUE r_stdout = rb_ractor_stdout();
    if (recv == r_stdout) {
        return rb_io_putc(recv, ch);
    }
    return forward(r_stdout, rb_intern(&quot;putc&quot;), 1, &amp;ch);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-puts" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          puts(*objects)    &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to</p>

<pre class="ruby"><span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">objects</span>)
</pre>

                              <div class="method-source-code" id="puts-source">
            <pre>static VALUE
rb_f_puts(int argc, VALUE *argv, VALUE recv)
{
    VALUE r_stdout = rb_ractor_stdout();
    if (recv == r_stdout) {
        return rb_io_puts(argc, argv, recv);
    }
    return forward(r_stdout, rb_intern(&quot;puts&quot;), argc, argv);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-raise" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          raise
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          raise(string, cause: $!)
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          raise(exception [, string [, array]], cause: $!)
                              </span>
                            </div>

                            <div class="method-description">
                              <p>With no arguments, raises the exception in <code>$!</code> or raises a <a href="RuntimeError.html"><code>RuntimeError</code></a> if <code>$!</code> is <code>nil</code>.  With a single <code>String</code> argument, raises a <code>RuntimeError</code> with the string as a message. Otherwise, the first parameter should be an <code>Exception</code> class (or another object that returns an <code>Exception</code> object when sent an <code>exception</code> message).  The optional second parameter sets the message associated with the exception (accessible via <a href="Exception.html#method-i-message"><code>Exception#message</code></a>), and the third parameter is an array of callback information (accessible via <a href="Exception.html#method-i-backtrace"><code>Exception#backtrace</code></a>). The <code>cause</code> of the generated exception (accessible via <a href="Exception.html#method-i-cause"><code>Exception#cause</code></a>) is automatically set to the “current” exception (<code>$!</code>), if any. An alternative value, either an <code>Exception</code> object or <code>nil</code>, can be specified via the <code>:cause</code> argument.</p>

<p>Exceptions are caught by the <code>rescue</code> clause of <code>begin...end</code> blocks.</p>

<pre class="ruby"><span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;Failed to create socket&quot;</span>
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;No parameters&quot;</span>, <span class="ruby-identifier">caller</span>
</pre>

                              <div class="method-source-code" id="raise-source">
            <pre>static VALUE
f_raise(int c, VALUE *v, VALUE _)
{
    return rb_f_raise(c, v);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Kernel.html#method-i-fail">fail</a>
                            </div>

                          </div>

                  <div id="method-i-rand" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          rand(max=0)    &rarr; number
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>If called without an argument, or if <code>max.to_i.abs == 0</code>, rand returns a pseudo-random floating point number between 0.0 and 1.0, including 0.0 and excluding 1.0.</p>

<pre class="ruby"><span class="ruby-identifier">rand</span>        <span class="ruby-comment">#=&gt; 0.2725926052826416</span>
</pre>

<p>When <code>max.abs</code> is greater than or equal to 1, <code>rand</code> returns a pseudo-random integer greater than or equal to 0 and less than <code>max.to_i.abs</code>.</p>

<pre class="ruby"><span class="ruby-identifier">rand</span>(<span class="ruby-value">100</span>)   <span class="ruby-comment">#=&gt; 12</span>
</pre>

<p>When <code>max</code> is a <a href="Range.html"><code>Range</code></a>, <code>rand</code> returns a random number where <code>range.member?(number) == true</code>.</p>

<p>Negative or floating point values for <code>max</code> are allowed, but may give surprising results.</p>

<pre class="ruby"><span class="ruby-identifier">rand</span>(<span class="ruby-value">-100</span>) <span class="ruby-comment"># =&gt; 87</span>
<span class="ruby-identifier">rand</span>(<span class="ruby-value">-0.5</span>) <span class="ruby-comment"># =&gt; 0.8130921818028143</span>
<span class="ruby-identifier">rand</span>(<span class="ruby-value">1.9</span>)  <span class="ruby-comment"># equivalent to rand(1), which is always 0</span>
</pre>

<p><a href="Kernel.html#method-i-srand"><code>Kernel.srand</code></a> may be used to ensure that sequences of random numbers are reproducible between different runs of a program.</p>

<p>See also <a href="Random.html#method-c-rand"><code>Random.rand</code></a>.</p>

                              <div class="method-source-code" id="rand-source">
            <pre>static VALUE
rb_f_rand(int argc, VALUE *argv, VALUE obj)
{
    VALUE vmax;
    rb_random_t *rnd = rand_start(default_rand());

    if (rb_check_arity(argc, 0, 1) &amp;&amp; !NIL_P(vmax = argv[0])) {
        VALUE v = rand_range(obj, rnd, vmax);
        if (v != Qfalse) return v;
        vmax = rb_to_int(vmax);
        if (vmax != INT2FIX(0)) {
            v = rand_int(obj, rnd, vmax, 0);
            if (!NIL_P(v)) return v;
        }
    }
    return DBL2NUM(random_real(obj, rnd, TRUE));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-readline" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          readline(sep = $/, chomp: false)   &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          readline(limit, chomp: false)      &rarr; string
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          readline(sep, limit, chomp: false) &rarr; string
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to method <a href="Kernel.html#method-i-gets"><code>Kernel#gets</code></a>, except that it raises an exception if called at end-of-stream:</p>

<pre>$ cat t.txt | ruby -e &quot;p readlines; readline&quot;
[&quot;First line\n&quot;, &quot;Second line\n&quot;, &quot;\n&quot;, &quot;Fourth line\n&quot;, &quot;Fifth line\n&quot;]
in `readline&#39;: end of file reached (EOFError)</pre>

<p>Optional keyword argument <code>chomp</code> specifies whether line separators are to be omitted.</p>

                              <div class="method-source-code" id="readline-source">
            <pre>static VALUE
rb_f_readline(int argc, VALUE *argv, VALUE recv)
{
    if (recv == argf) {
        return argf_readline(argc, argv, argf);
    }
    return forward(argf, rb_intern(&quot;readline&quot;), argc, argv);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-readlines" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          readlines(sep = $/, chomp: false, **enc_opts)   &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          readlines(limit, chomp: false, **enc_opts)       &rarr; array
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          readlines(sep, limit, chomp: false, **enc_opts) &rarr; array
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array containing the lines returned by calling <a href="Kernel.html#method-i-gets"><code>Kernel#gets</code></a> until the end-of-stream is reached; (see <a href="IO.html#class-IO-label-Line+IO">Line IO</a>).</p>

<p>With only string argument <code>sep</code> given, returns the remaining lines as determined by line separator <code>sep</code>, or <code>nil</code> if none; see <a href="IO.html#class-IO-label-Line+Separator">Line Separator</a>:</p>

<pre># Default separator.
$ cat t.txt | ruby -e &quot;p readlines&quot;
[&quot;First line\n&quot;, &quot;Second line\n&quot;, &quot;\n&quot;, &quot;Fourth line\n&quot;, &quot;Fifth line\n&quot;]

# Specified separator.
$ cat t.txt | ruby -e &quot;p readlines &#39;li&#39;&quot;
[&quot;First li&quot;, &quot;ne\nSecond li&quot;, &quot;ne\n\nFourth li&quot;, &quot;ne\nFifth li&quot;, &quot;ne\n&quot;]

# Get-all separator.
$ cat t.txt | ruby -e &quot;p readlines nil&quot;
[&quot;First line\nSecond line\n\nFourth line\nFifth line\n&quot;]

# Get-paragraph separator.
$ cat t.txt | ruby -e &quot;p readlines &#39;&#39;&quot;
[&quot;First line\nSecond line\n\n&quot;, &quot;Fourth line\nFifth line\n&quot;]</pre>

<p>With only integer argument <code>limit</code> given, limits the number of bytes in the line; see <a href="IO.html#class-IO-label-Line+Limit">Line Limit</a>:</p>

<pre>$cat t.txt | ruby -e &quot;p readlines 10&quot;
[&quot;First line&quot;, &quot;\n&quot;, &quot;Second lin&quot;, &quot;e\n&quot;, &quot;\n&quot;, &quot;Fourth lin&quot;, &quot;e\n&quot;, &quot;Fifth line&quot;, &quot;\n&quot;]

$cat t.txt | ruby -e &quot;p readlines 11&quot;
[&quot;First line\n&quot;, &quot;Second line&quot;, &quot;\n&quot;, &quot;\n&quot;, &quot;Fourth line&quot;, &quot;\n&quot;, &quot;Fifth line\n&quot;]

$cat t.txt | ruby -e &quot;p readlines 12&quot;
[&quot;First line\n&quot;, &quot;Second line\n&quot;, &quot;\n&quot;, &quot;Fourth line\n&quot;, &quot;Fifth line\n&quot;]</pre>

<p>With arguments <code>sep</code> and <code>limit</code> given, combines the two behaviors; see <a href="IO.html#class-IO-label-Line+Separator+and+Line+Limit">Line Separator and Line Limit</a>.</p>

<p>Optional keyword argument <code>chomp</code> specifies whether line separators are to be omitted:</p>

<pre>$ cat t.txt | ruby -e &quot;p readlines(chomp: true)&quot;
[&quot;First line&quot;, &quot;Second line&quot;, &quot;&quot;, &quot;Fourth line&quot;, &quot;Fifth line&quot;]</pre>

<p>Optional keyword arguments <code>enc_opts</code> specify encoding options; see <a href="encodings_rdoc.html#label-Encoding+Options">Encoding options</a>.</p>

                              <div class="method-source-code" id="readlines-source">
            <pre>static VALUE
rb_f_readlines(int argc, VALUE *argv, VALUE recv)
{
    if (recv == argf) {
        return argf_readlines(argc, argv, argf);
    }
    return forward(argf, rb_intern(&quot;readlines&quot;), argc, argv);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-require" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          require(name)    &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Loads the given <code>name</code>, returning <code>true</code> if successful and <code>false</code> if the feature is already loaded.</p>

<p>If the filename neither resolves to an absolute path nor starts with ‘./’ or ‘../’, the file will be searched for in the library directories listed in <code>$LOAD_PATH</code> (<code>$:</code>). If the filename starts with ‘./’ or ‘../’, resolution is based on <a href="Dir.html#method-c-pwd"><code>Dir.pwd</code></a>.</p>

<p>If the filename has the extension “.rb”, it is loaded as a source file; if the extension is “.so”, “.o”, or “.dll”, or the default shared library extension on the current platform, Ruby loads the shared library as a Ruby extension.  Otherwise, Ruby tries adding “.rb”, “.so”, and so on to the name until found.  If the file named cannot be found, a <a href="LoadError.html"><code>LoadError</code></a> will be raised.</p>

<p>For Ruby extensions the filename given may use any shared library extension.  For example, on Linux the socket extension is “socket.so” and <code>require &#39;socket.dll&#39;</code> will load the socket extension.</p>

<p>The absolute path of the loaded file is added to <code>$LOADED_FEATURES</code> (<code>$&quot;</code>).  A file will not be loaded again if its path already appears in <code>$&quot;</code>.  For example, <code>require &#39;a&#39;; require &#39;./a&#39;</code> will not load <code>a.rb</code> again.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&quot;my-library.rb&quot;</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;db-driver&quot;</span>
</pre>

<p>Any constants or globals within the loaded source file will be available in the calling program’s global namespace. However, local variables will not be propagated to the loading environment.</p>

                              <div class="method-source-code" id="require-source">
            <pre>VALUE
rb_f_require(VALUE obj, VALUE fname)
{
    return rb_require_string(fname);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-require_relative" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          require_relative(string) &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Ruby tries to load the library named <em>string</em> relative to the directory containing the requiring file.  If the file does not exist a <a href="LoadError.html"><code>LoadError</code></a> is raised. Returns <code>true</code> if the file was loaded and <code>false</code> if the file was already loaded before.</p>

                              <div class="method-source-code" id="require_relative-source">
            <pre>VALUE
rb_f_require_relative(VALUE obj, VALUE fname)
{
    VALUE base = rb_current_realfilepath();
    if (NIL_P(base)) {
        rb_loaderror(&quot;cannot infer basepath&quot;);
    }
    base = rb_file_dirname(base);
    return rb_require_string(rb_file_absolute_path(fname, base));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-select" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          select(read_ios, write_ios = [], error_ios = [], timeout = nil) &rarr; array or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Invokes system call <a href="https://linux.die.net/man/2/select">select(2)</a>, which monitors multiple file descriptors, waiting until one or more of the file descriptors becomes ready for some class of I/O operation.</p>

<p>Not implemented on all platforms.</p>

<p>Each of the arguments <code>read_ios</code>, <code>write_ios</code>, and <code>error_ios</code> is an array of <a href="IO.html"><code>IO</code></a> objects.</p>

<p>Argument <code>timeout</code> is an integer timeout interval in seconds.</p>

<p>The method monitors the IO objects given in all three arrays, waiting for some to be ready; returns a 3-element array whose elements are:</p>
<ul><li>
<p>An array of the objects in <code>read_ios</code> that are ready for reading.</p>
</li><li>
<p>An array of the objects in <code>write_ios</code> that are ready for writing.</p>
</li><li>
<p>An array of the objects in <code>error_ios</code> have pending exceptions.</p>
</li></ul>

<p>If no object becomes ready within the given <code>timeout</code>, <code>nil</code> is returned.</p>

<p>IO.select peeks the buffer of IO objects for testing readability. If the IO buffer is not empty, IO.select immediately notifies readability.  This “peek” only happens for IO objects.  It does not happen for IO-like objects such as OpenSSL::SSL::SSLSocket.</p>

<p>The best way to use IO.select is invoking it after non-blocking methods such as read_nonblock, write_nonblock, etc.  The methods raise an exception which is extended by <a href="IO/WaitReadable.html"><code>IO::WaitReadable</code></a> or <a href="IO/WaitWritable.html"><code>IO::WaitWritable</code></a>.  The modules notify how the caller should wait with IO.select.  If <a href="IO/WaitReadable.html"><code>IO::WaitReadable</code></a> is raised, the caller should wait for reading.  If <a href="IO/WaitWritable.html"><code>IO::WaitWritable</code></a> is raised, the caller should wait for writing.</p>

<p>So, blocking read (readpartial) can be emulated using read_nonblock and IO.select as follows:</p>

<pre class="ruby"><span class="ruby-keyword">begin</span>
  <span class="ruby-identifier">result</span> = <span class="ruby-identifier">io_like</span>.<span class="ruby-identifier">read_nonblock</span>(<span class="ruby-identifier">maxlen</span>)
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitReadable</span>
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>([<span class="ruby-identifier">io_like</span>])
  <span class="ruby-keyword">retry</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitWritable</span>
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>(<span class="ruby-keyword">nil</span>, [<span class="ruby-identifier">io_like</span>])
  <span class="ruby-keyword">retry</span>
<span class="ruby-keyword">end</span>
</pre>

<p>Especially, the combination of non-blocking methods and IO.select is preferred for <a href="IO.html"><code>IO</code></a> like objects such as OpenSSL::SSL::SSLSocket.  It has to_io method to return underlying <a href="IO.html"><code>IO</code></a> object.  <a href="IO.html#method-c-select"><code>IO.select</code></a> calls to_io to obtain the file descriptor to wait.</p>

<p>This means that readability notified by IO.select doesn’t mean readability from OpenSSL::SSL::SSLSocket object.</p>

<p>The most likely situation is that OpenSSL::SSL::SSLSocket buffers some data.  IO.select doesn’t see the buffer.  So IO.select can block when OpenSSL::SSL::SSLSocket#readpartial doesn’t block.</p>

<p>However, several more complicated situations exist.</p>

<p>SSL is a protocol which is sequence of records. The record consists of multiple bytes. So, the remote side of SSL sends a partial record, <a href="IO.html#method-c-select"><code>IO.select</code></a> notifies readability but OpenSSL::SSL::SSLSocket cannot decrypt a byte and OpenSSL::SSL::SSLSocket#readpartial will block.</p>

<p>Also, the remote side can request SSL renegotiation which forces the local SSL engine to write some data. This means OpenSSL::SSL::SSLSocket#readpartial may invoke write system call and it can block. In such a situation, OpenSSL::SSL::SSLSocket#read_nonblock raises <a href="IO/WaitWritable.html"><code>IO::WaitWritable</code></a> instead of blocking. So, the caller should wait for ready for writability as above example.</p>

<p>The combination of non-blocking methods and IO.select is also useful for streams such as tty, pipe socket socket when multiple processes read from a stream.</p>

<p>Finally, Linux kernel developers don’t guarantee that readability of select(2) means readability of following read(2) even for a single process; see <a href="https://linux.die.net/man/2/select">select(2)</a></p>

<p>Invoking IO.select before <a href="IO.html#method-i-readpartial"><code>IO#readpartial</code></a> works well as usual. However it is not the best way to use IO.select.</p>

<p>The writability notified by select(2) doesn’t show how many bytes are writable. <a href="IO.html#method-i-write"><code>IO#write</code></a> method blocks until given whole string is written. So, <code>IO#write(two or more bytes)</code> can block after writability is notified by IO.select.  <a href="IO.html#method-i-write_nonblock"><code>IO#write_nonblock</code></a> is required to avoid the blocking.</p>

<p>Blocking write (write) can be emulated using write_nonblock and <a href="IO.html#method-c-select"><code>IO.select</code></a> as follows: <a href="IO/WaitReadable.html"><code>IO::WaitReadable</code></a> should also be rescued for SSL renegotiation in OpenSSL::SSL::SSLSocket.</p>

<pre class="ruby"><span class="ruby-keyword">while</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">string</span>.<span class="ruby-identifier">bytesize</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">written</span> = <span class="ruby-identifier">io_like</span>.<span class="ruby-identifier">write_nonblock</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitReadable</span>
    <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>([<span class="ruby-identifier">io_like</span>])
    <span class="ruby-keyword">retry</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitWritable</span>
    <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>(<span class="ruby-keyword">nil</span>, [<span class="ruby-identifier">io_like</span>])
    <span class="ruby-keyword">retry</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">string</span> = <span class="ruby-identifier">string</span>.<span class="ruby-identifier">byteslice</span>(<span class="ruby-identifier">written</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>)
<span class="ruby-keyword">end</span>
</pre>

<p>Example:</p>

<pre class="ruby"><span class="ruby-identifier">rp</span>, <span class="ruby-identifier">wp</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">pipe</span>
<span class="ruby-identifier">mesg</span> = <span class="ruby-string">&quot;ping &quot;</span>
<span class="ruby-value">100</span>.<span class="ruby-identifier">times</span> {
  <span class="ruby-comment"># IO.select follows IO#read.  Not the best way to use IO.select.</span>
  <span class="ruby-identifier">rs</span>, <span class="ruby-identifier">ws</span>, = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>([<span class="ruby-identifier">rp</span>], [<span class="ruby-identifier">wp</span>])
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">r</span> = <span class="ruby-identifier">rs</span>[<span class="ruby-value">0</span>]
    <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">r</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">5</span>)
    <span class="ruby-identifier">print</span> <span class="ruby-identifier">ret</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">ret</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/ping/</span>
      <span class="ruby-identifier">mesg</span> = <span class="ruby-string">&quot;pong\n&quot;</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/pong/</span>
      <span class="ruby-identifier">mesg</span> = <span class="ruby-string">&quot;ping &quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">w</span> = <span class="ruby-identifier">ws</span>[<span class="ruby-value">0</span>]
    <span class="ruby-identifier">w</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">mesg</span>)
  <span class="ruby-keyword">end</span>
}
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-identifier">ping</span> <span class="ruby-identifier">pong</span>
<span class="ruby-identifier">ping</span> <span class="ruby-identifier">pong</span>
<span class="ruby-identifier">ping</span> <span class="ruby-identifier">pong</span>
(<span class="ruby-identifier">snipped</span>)
<span class="ruby-identifier">ping</span>
</pre>

                              <div class="method-source-code" id="select-source">
            <pre>static VALUE
rb_f_select(int argc, VALUE *argv, VALUE obj)
{
    VALUE scheduler = rb_fiber_scheduler_current();
    if (scheduler != Qnil) {
        // It&#39;s optionally supported.
        VALUE result = rb_fiber_scheduler_io_selectv(scheduler, argc, argv);
        if (!UNDEF_P(result)) return result;
    }

    VALUE timeout;
    struct select_args args;
    struct timeval timerec;
    int i;

    rb_scan_args(argc, argv, &quot;13&quot;, &amp;args.read, &amp;args.write, &amp;args.except, &amp;timeout);
    if (NIL_P(timeout)) {
        args.timeout = 0;
    }
    else {
        timerec = rb_time_interval(timeout);
        args.timeout = &amp;timerec;
    }

    for (i = 0; i &lt; numberof(args.fdsets); ++i)
        rb_fd_init(&amp;args.fdsets[i]);

    return rb_ensure(select_call, (VALUE)&amp;args, select_end, (VALUE)&amp;args);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_trace_func" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          set_trace_func(proc)    &rarr; proc
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          set_trace_func(nil)     &rarr; nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Establishes <em>proc</em> as the handler for tracing, or disables tracing if the parameter is <code>nil</code>.</p>

<p><strong>Note:</strong> this method is obsolete, please use <a href="TracePoint.html"><code>TracePoint</code></a> instead.</p>

<p><em>proc</em> takes up to six parameters:</p>
<ul><li>
<p>an event name string</p>
</li><li>
<p>a filename string</p>
</li><li>
<p>a line number</p>
</li><li>
<p>a method name symbol, or nil</p>
</li><li>
<p>a binding, or nil</p>
</li><li>
<p>the class, module, or nil</p>
</li></ul>

<p><em>proc</em> is invoked whenever an event occurs.</p>

<p>Events are:</p>
<dl class="rdoc-list note-list"><dt><code>&quot;c-call&quot;</code>
<dd>
<p>call a C-language routine</p>
</dd><dt><code>&quot;c-return&quot;</code>
<dd>
<p>return from a C-language routine</p>
</dd><dt><code>&quot;call&quot;</code>
<dd>
<p>call a Ruby method</p>
</dd><dt><code>&quot;class&quot;</code>
<dd>
<p>start a class or module definition</p>
</dd><dt><code>&quot;end&quot;</code>
<dd>
<p>finish a class or module definition</p>
</dd><dt><code>&quot;line&quot;</code>
<dd>
<p>execute code on a new line</p>
</dd><dt><code>&quot;raise&quot;</code>
<dd>
<p>raise an exception</p>
</dd><dt><code>&quot;return&quot;</code>
<dd>
<p>return from a Ruby method</p>
</dd></dl>

<p>Tracing is disabled within the context of <em>proc</em>.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Test</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test</span>
    <span class="ruby-identifier">a</span> = <span class="ruby-value">1</span>
    <span class="ruby-identifier">b</span> = <span class="ruby-value">2</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">set_trace_func</span> <span class="ruby-identifier">proc</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">event</span>, <span class="ruby-identifier">file</span>, <span class="ruby-identifier">line</span>, <span class="ruby-identifier">id</span>, <span class="ruby-identifier">binding</span>, <span class="ruby-identifier">class_or_module</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">printf</span> <span class="ruby-string">&quot;%8s %s:%-2d %16p %14p\n&quot;</span>, <span class="ruby-identifier">event</span>, <span class="ruby-identifier">file</span>, <span class="ruby-identifier">line</span>, <span class="ruby-identifier">id</span>, <span class="ruby-identifier">class_or_module</span>
}
<span class="ruby-identifier">t</span> = <span class="ruby-constant">Test</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">test</span>
</pre>

<p>Produces:</p>

<pre>c-return prog.rb:8   :set_trace_func         Kernel
    line prog.rb:11              nil            nil
  c-call prog.rb:11             :new          Class
  c-call prog.rb:11      :initialize    BasicObject
c-return prog.rb:11      :initialize    BasicObject
c-return prog.rb:11             :new          Class
    line prog.rb:12              nil            nil
    call prog.rb:2             :test           Test
    line prog.rb:3             :test           Test
    line prog.rb:4             :test           Test
  return prog.rb:5             :test           Test</pre>

                              <div class="method-source-code" id="set_trace_func-source">
            <pre>static VALUE
set_trace_func(VALUE obj, VALUE trace)
{
    rb_remove_event_hook(call_trace_func);

    if (NIL_P(trace)) {
        return Qnil;
    }

    if (!rb_obj_is_proc(trace)) {
        rb_raise(rb_eTypeError, &quot;trace_func needs to be Proc&quot;);
    }

    rb_add_event_hook(call_trace_func, RUBY_EVENT_ALL, trace);
    return trace;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sleep" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          sleep(secs = nil) &rarr; slept_secs
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Suspends execution of the current thread for the number of seconds specified by numeric argument <code>secs</code>, or forever if <code>secs</code> is <code>nil</code>; returns the integer number of seconds suspended (rounded).</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>  <span class="ruby-comment"># =&gt; 2008-03-08 19:56:19 +0900</span>
<span class="ruby-identifier">sleep</span> <span class="ruby-value">1.2</span> <span class="ruby-comment"># =&gt; 1</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>  <span class="ruby-comment"># =&gt; 2008-03-08 19:56:20 +0900</span>
<span class="ruby-identifier">sleep</span> <span class="ruby-value">1.9</span> <span class="ruby-comment"># =&gt; 2</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>  <span class="ruby-comment"># =&gt; 2008-03-08 19:56:22 +0900</span>
</pre>

                              <div class="method-source-code" id="sleep-source">
            <pre>static VALUE
rb_f_sleep(int argc, VALUE *argv, VALUE _)
{
    time_t beg = time(0);
    VALUE scheduler = rb_fiber_scheduler_current();

    if (scheduler != Qnil) {
        rb_fiber_scheduler_kernel_sleepv(scheduler, argc, argv);
    }
    else {
        if (argc == 0 || (argc == 1 &amp;&amp; NIL_P(argv[0]))) {
            rb_thread_sleep_forever();
        }
        else {
            rb_check_arity(argc, 0, 1);
            rb_thread_wait_for(rb_time_interval(argv[0]));
        }
    }

    time_t end = time(0) - beg;

    return TIMET2NUM(end);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-spawn" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          spawn([env, ] command_line, options = {}) &rarr; pid
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          spawn([env, ] exe_path, *args, options  = {}) &rarr; pid
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new child process by doing one of the following in that process:</p>
<ul><li>
<p>Passing string <code>command_line</code> to the shell.</p>
</li><li>
<p>Invoking the executable at <code>exe_path</code>.</p>
</li></ul>

<p>This method has potential security vulnerabilities if called with untrusted input; see <a href="command_injection_rdoc.html">Command Injection</a>.</p>

<p>Returns the process ID (pid) of the new process, without waiting for it to complete.</p>

<p>To avoid zombie processes, the parent process should call either:</p>
<ul><li>
<p><a href="Process.html#method-c-wait"><code>Process.wait</code></a>, to collect the termination statuses of its children.</p>
</li><li>
<p><a href="Process.html#method-c-detach"><code>Process.detach</code></a>, to register disinterest in their status.</p>
</li></ul>

<p>The new process is created using the <a href="https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/execve.html">exec system call</a>; it may inherit some of its environment from the calling program (possibly including open file descriptors).</p>

<p>Argument <code>env</code>, if given, is a hash that affects <code>ENV</code> for the new process; see <a href="Process.html#module-Process-label-Execution+Environment">Execution Environment</a>.</p>

<p>Argument <code>options</code> is a hash of options for the new process; see <a href="Process.html#module-Process-label-Execution+Options">Execution Options</a>.</p>

<p>The first required argument is one of the following:</p>
<ul><li>
<p><code>command_line</code> if it is a string, and if it begins with a shell reserved word or special built-in, or if it contains one or more metacharacters.</p>
</li><li>
<p><code>exe_path</code> otherwise.</p>
</li></ul>

<p><strong>Argument <code>command_line</code></strong></p>

<p>String argument <code>command_line</code> is a command line to be passed to a shell; it must begin with a shell reserved word, begin with a special built-in, or contain meta characters:</p>

<pre class="ruby"><span class="ruby-identifier">spawn</span>(<span class="ruby-string">&#39;echo&#39;</span>)                         <span class="ruby-comment"># =&gt; 798847</span>
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">wait</span>                          <span class="ruby-comment"># =&gt; 798847</span>
<span class="ruby-identifier">spawn</span>(<span class="ruby-string">&#39;if true; then echo &quot;Foo&quot;; fi&#39;</span>) <span class="ruby-comment"># =&gt; 798848</span>
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">wait</span>                          <span class="ruby-comment"># =&gt; 798848</span>
<span class="ruby-identifier">spawn</span>(<span class="ruby-string">&#39;date &gt; /tmp/date.tmp&#39;</span>)         <span class="ruby-comment"># =&gt; 798879</span>
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">wait</span>                          <span class="ruby-comment"># =&gt; 798849</span>
<span class="ruby-identifier">spawn</span>(<span class="ruby-string">&#39;date &gt; /nop/date.tmp&#39;</span>)         <span class="ruby-comment"># =&gt; 798882 # Issues error message.</span>
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">wait</span>                          <span class="ruby-comment"># =&gt; 798882</span>
</pre>

<p>The command line may also contain arguments and options for the command:</p>

<pre class="ruby"><span class="ruby-identifier">spawn</span>(<span class="ruby-string">&#39;echo &quot;Foo&quot;&#39;</span>) <span class="ruby-comment"># =&gt; 799031</span>
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">wait</span>        <span class="ruby-comment"># =&gt; 799031</span>
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-constant">Foo</span>
</pre>

<p>On a Unix-like system, the shell is <code>/bin/sh</code>; otherwise the shell is determined by environment variable <code>ENV[&#39;RUBYSHELL&#39;]</code>, if defined, or <code>ENV[&#39;COMSPEC&#39;]</code> otherwise.</p>

<p>Except for the <code>COMSPEC</code> case, the entire string <code>command_line</code> is passed as an argument to <a href="https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/sh.html">shell option -c</a>.</p>

<p>The shell performs normal shell expansion on the command line:</p>

<pre class="ruby"><span class="ruby-identifier">spawn</span>(<span class="ruby-string">&#39;echo C*&#39;</span>) <span class="ruby-comment"># =&gt; 799139</span>
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">wait</span>     <span class="ruby-comment"># =&gt; 799139</span>
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-constant">CONTRIBUTING</span>.<span class="ruby-identifier">md</span> <span class="ruby-constant">COPYING</span> <span class="ruby-constant">COPYING</span>.<span class="ruby-identifier">ja</span>
</pre>

<p>Raises an exception if the new process could not execute.</p>

<p><strong>Argument <code>exe_path</code></strong></p>

<p>Argument <code>exe_path</code> is one of the following:</p>
<ul><li>
<p>The string path to an executable to be called.</p>
</li><li>
<p>A 2-element array containing the path to an executable and the string to be used as the name of the executing process.</p>
</li></ul>

<p>Example:</p>

<pre class="ruby"><span class="ruby-identifier">spawn</span>(<span class="ruby-string">&#39;/usr/bin/date&#39;</span>) <span class="ruby-comment"># =&gt; 799198 # Path to date on Unix-style system.</span>
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">wait</span>           <span class="ruby-comment"># =&gt; 799198</span>
</pre>

<p>Output:</p>

<pre>Thu Aug 31 10:06:48 AM CDT 2023</pre>

<p>Ruby invokes the executable directly, with no shell and no shell expansion.</p>

<p>If one or more <code>args</code> is given, each is an argument or option to be passed to the executable:</p>

<pre class="ruby"><span class="ruby-identifier">spawn</span>(<span class="ruby-string">&#39;echo&#39;</span>, <span class="ruby-string">&#39;C*&#39;</span>)             <span class="ruby-comment"># =&gt; 799392</span>
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">wait</span>                    <span class="ruby-comment"># =&gt; 799392</span>
<span class="ruby-identifier">spawn</span>(<span class="ruby-string">&#39;echo&#39;</span>, <span class="ruby-string">&#39;hello&#39;</span>, <span class="ruby-string">&#39;world&#39;</span>) <span class="ruby-comment"># =&gt; 799393</span>
<span class="ruby-constant">Process</span>.<span class="ruby-identifier">wait</span>                    <span class="ruby-comment"># =&gt; 799393</span>
</pre>

<p>Output:</p>

<pre>C*
hello world</pre>

<p>Raises an exception if the new process could not execute.</p>

                              <div class="method-source-code" id="spawn-source">
            <pre>static VALUE
rb_f_spawn(int argc, VALUE *argv, VALUE _)
{
    rb_pid_t pid;
    char errmsg[CHILD_ERRMSG_BUFLEN] = { &#39;\0&#39; };
    VALUE execarg_obj, fail_str;
    struct rb_execarg *eargp;

    execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE);
    eargp = rb_execarg_get(execarg_obj);
    fail_str = eargp-&gt;use_shell ? eargp-&gt;invoke.sh.shell_script : eargp-&gt;invoke.cmd.command_name;

    pid = rb_execarg_spawn(execarg_obj, errmsg, sizeof(errmsg));

    if (pid == -1) {
        int err = errno;
        rb_exec_fail(eargp, err, errmsg);
        RB_GC_GUARD(execarg_obj);
        rb_syserr_fail_str(err, fail_str);
    }
#if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV)
    return PIDT2NUM(pid);
#else
    return Qnil;
#endif
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sprintf" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          sprintf(format_string *objects)  &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the string resulting from formatting <code>objects</code> into <code>format_string</code>.</p>

<p>For details on <code>format_string</code>, see <a href="format_specifications_rdoc.html">Format Specifications</a>.</p>

                              <div class="method-source-code" id="sprintf-source">
            <pre>static VALUE
f_sprintf(int c, const VALUE *v, VALUE _)
{
    return rb_f_sprintf(c, v);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Kernel.html#method-i-format">format</a>
                            </div>

                          </div>

                  <div id="method-i-srand" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          srand(number = Random.new_seed) &rarr; old_seed
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Seeds the system pseudo-random number generator, with <code>number</code>. The previous seed value is returned.</p>

<p>If <code>number</code> is omitted, seeds the generator using a source of entropy provided by the operating system, if available (/dev/urandom on Unix systems or the RSA cryptographic provider on Windows), which is then combined with the time, the process id, and a sequence number.</p>

<p>srand may be used to ensure repeatable sequences of pseudo-random numbers between different runs of the program. By setting the seed to a known value, programs can be made deterministic during testing.</p>

<pre class="ruby"><span class="ruby-identifier">srand</span> <span class="ruby-value">1234</span>               <span class="ruby-comment"># =&gt; 268519324636777531569100071560086917274</span>
[ <span class="ruby-identifier">rand</span>, <span class="ruby-identifier">rand</span> ]           <span class="ruby-comment"># =&gt; [0.1915194503788923, 0.6221087710398319]</span>
[ <span class="ruby-identifier">rand</span>(<span class="ruby-value">10</span>), <span class="ruby-identifier">rand</span>(<span class="ruby-value">1000</span>) ] <span class="ruby-comment"># =&gt; [4, 664]</span>
<span class="ruby-identifier">srand</span> <span class="ruby-value">1234</span>               <span class="ruby-comment"># =&gt; 1234</span>
[ <span class="ruby-identifier">rand</span>, <span class="ruby-identifier">rand</span> ]           <span class="ruby-comment"># =&gt; [0.1915194503788923, 0.6221087710398319]</span>
</pre>

                              <div class="method-source-code" id="srand-source">
            <pre>static VALUE
rb_f_srand(int argc, VALUE *argv, VALUE obj)
{
    VALUE seed, old;
    rb_random_mt_t *r = rand_mt_start(default_rand());

    if (rb_check_arity(argc, 0, 1) == 0) {
        seed = random_seed(obj);
    }
    else {
        seed = rb_to_int(argv[0]);
    }
    old = r-&gt;base.seed;
    rand_init(&amp;random_mt_if, &amp;r-&gt;base, seed);
    r-&gt;base.seed = seed;

    return old;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sub" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          sub(pattern, replacement)   &rarr; $_
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          sub(pattern) {|...| block } &rarr; $_
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to <code>$_.sub(<em>args</em>)</code>, except that <code>$_</code> will be updated if substitution occurs. Available only when -p/-n command line option specified.</p>

                              <div class="method-source-code" id="sub-source">
            <pre>static VALUE
rb_f_sub(int argc, VALUE *argv, VALUE _)
{
    VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern(&quot;sub&quot;), argc, argv);
    rb_lastline_set(str);
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-syscall" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          syscall(integer_callno, *arguments)   &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Invokes Posix system call <a href="https://linux.die.net/man/2/syscall">syscall(2)</a>, which calls a specified function.</p>

<p>Calls the operating system function identified by <code>integer_callno</code>; returns the result of the function or raises <a href="SystemCallError.html"><code>SystemCallError</code></a> if it failed. The effect of the call is platform-dependent. The arguments and returned value are platform-dependent.</p>

<p>For each of <code>arguments</code>: if it is an integer, it is passed directly; if it is a string, it is interpreted as a binary sequence of bytes. There may be as many as nine such arguments.</p>

<p>Arguments <code>integer_callno</code> and <code>argument</code>, as well as the returned value, are platform-dependent.</p>

<p>Note: <a href="Method.html"><code>Method</code></a> <code>syscall</code> is essentially unsafe and unportable. The DL (Fiddle) library is preferred for safer and a bit more portable programming.</p>

<p>Not implemented on all platforms.</p>

                              <div class="method-source-code" id="syscall-source">
            <pre>static VALUE
rb_f_syscall(int argc, VALUE *argv, VALUE _)
{
    VALUE arg[8];
#if SIZEOF_VOIDP == 8 &amp;&amp; defined(HAVE___SYSCALL) &amp;&amp; SIZEOF_INT != 8 /* mainly *BSD */
# define SYSCALL __syscall
# define NUM2SYSCALLID(x) NUM2LONG(x)
# define RETVAL2NUM(x) LONG2NUM(x)
# if SIZEOF_LONG == 8
    long num, retval = -1;
# elif SIZEOF_LONG_LONG == 8
    long long num, retval = -1;
# else
#  error ----&gt;&gt; it is asserted that __syscall takes the first argument and returns retval in 64bit signed integer. &lt;&lt;----
# endif
#elif defined(__linux__)
# define SYSCALL syscall
# define NUM2SYSCALLID(x) NUM2LONG(x)
# define RETVAL2NUM(x) LONG2NUM(x)
    /*
     * Linux man page says, syscall(2) function prototype is below.
     *
     *     int syscall(int number, ...);
     *
     * But, it&#39;s incorrect. Actual one takes and returned long. (see unistd.h)
     */
    long num, retval = -1;
#else
# define SYSCALL syscall
# define NUM2SYSCALLID(x) NUM2INT(x)
# define RETVAL2NUM(x) INT2NUM(x)
    int num, retval = -1;
#endif
    int i;

    if (RTEST(ruby_verbose)) {
        rb_category_warning(RB_WARN_CATEGORY_DEPRECATED,
            &quot;We plan to remove a syscall function at future release. DL(Fiddle) provides safer alternative.&quot;);
    }

    if (argc == 0)
        rb_raise(rb_eArgError, &quot;too few arguments for syscall&quot;);
    if (argc &gt; numberof(arg))
        rb_raise(rb_eArgError, &quot;too many arguments for syscall&quot;);
    num = NUM2SYSCALLID(argv[0]); ++argv;
    for (i = argc - 1; i--; ) {
        VALUE v = rb_check_string_type(argv[i]);

        if (!NIL_P(v)) {
            SafeStringValue(v);
            rb_str_modify(v);
            arg[i] = (VALUE)StringValueCStr(v);
        }
        else {
            arg[i] = (VALUE)NUM2LONG(argv[i]);
        }
    }

    switch (argc) {
      case 1:
        retval = SYSCALL(num);
        break;
      case 2:
        retval = SYSCALL(num, arg[0]);
        break;
      case 3:
        retval = SYSCALL(num, arg[0],arg[1]);
        break;
      case 4:
        retval = SYSCALL(num, arg[0],arg[1],arg[2]);
        break;
      case 5:
        retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3]);
        break;
      case 6:
        retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3],arg[4]);
        break;
      case 7:
        retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3],arg[4],arg[5]);
        break;
      case 8:
        retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6]);
        break;
    }

    if (retval == -1)
        rb_sys_fail(0);
    return RETVAL2NUM(retval);
#undef SYSCALL
#undef NUM2SYSCALLID
#undef RETVAL2NUM
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-system" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          system([env, ] command_line, options = {}, exception: false) &rarr; true, false, or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          system([env, ] exe_path, *args, options  = {}, exception: false) &rarr; true, false, or nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new child process by doing one of the following in that process:</p>
<ul><li>
<p>Passing string <code>command_line</code> to the shell.</p>
</li><li>
<p>Invoking the executable at <code>exe_path</code>.</p>
</li></ul>

<p>This method has potential security vulnerabilities if called with untrusted input; see <a href="command_injection_rdoc.html">Command Injection</a>.</p>

<p>Returns:</p>
<ul><li>
<p><code>true</code> if the command exits with status zero.</p>
</li><li>
<p><code>false</code> if the exit status is a non-zero integer.</p>
</li><li>
<p><code>nil</code> if the command could not execute.</p>
</li></ul>

<p>Raises an exception (instead of returning <code>false</code> or <code>nil</code>) if keyword argument <code>exception</code> is set to <code>true</code>.</p>

<p>Assigns the command’s error status to <code>$?</code>.</p>

<p>The new process is created using the <a href="https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/system.html">system system call</a>; it may inherit some of its environment from the calling program (possibly including open file descriptors).</p>

<p>Argument <code>env</code>, if given, is a hash that affects <code>ENV</code> for the new process; see <a href="Process.html#module-Process-label-Execution+Environment">Execution Environment</a>.</p>

<p>Argument <code>options</code> is a hash of options for the new process; see <a href="Process.html#module-Process-label-Execution+Options">Execution Options</a>.</p>

<p>The first required argument is one of the following:</p>
<ul><li>
<p><code>command_line</code> if it is a string, and if it begins with a shell reserved word or special built-in, or if it contains one or more metacharacters.</p>
</li><li>
<p><code>exe_path</code> otherwise.</p>
</li></ul>

<p><strong>Argument <code>command_line</code></strong></p>

<p>String argument <code>command_line</code> is a command line to be passed to a shell; it must begin with a shell reserved word, begin with a special built-in, or contain meta characters:</p>

<pre class="ruby"><span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;echo&#39;</span>)                                  <span class="ruby-comment"># =&gt; true  # Built-in.</span>
<span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;if true; then echo &quot;Foo&quot;; fi&#39;</span>)          <span class="ruby-comment"># =&gt; true  # Shell reserved word.</span>
<span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;date &gt; /tmp/date.tmp&#39;</span>)                  <span class="ruby-comment"># =&gt; true  # Contains meta character.</span>
<span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;date &gt; /nop/date.tmp&#39;</span>)                  <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;date &gt; /nop/date.tmp&#39;</span>, <span class="ruby-value">exception:</span> <span class="ruby-keyword">true</span>) <span class="ruby-comment"># Raises RuntimeError.</span>
</pre>

<p>Assigns the command’s error status to <code>$?</code>:</p>

<pre class="ruby"><span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;echo&#39;</span>)                             <span class="ruby-comment"># =&gt; true  # Built-in.</span>
<span class="ruby-identifier">$?</span>                                         <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid 640610 exit 0&gt;</span>
<span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;date &gt; /nop/date.tmp&#39;</span>)             <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">$?</span>                                         <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid 640742 exit 2&gt;</span>
</pre>

<p>The command line may also contain arguments and options for the command:</p>

<pre class="ruby"><span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;echo &quot;Foo&quot;&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-constant">Foo</span>
</pre>

<p>On a Unix-like system, the shell is <code>/bin/sh</code>; otherwise the shell is determined by environment variable <code>ENV[&#39;RUBYSHELL&#39;]</code>, if defined, or <code>ENV[&#39;COMSPEC&#39;]</code> otherwise.</p>

<p>Except for the <code>COMSPEC</code> case, the entire string <code>command_line</code> is passed as an argument to <a href="https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/sh.html">shell option -c</a>.</p>

<p>The shell performs normal shell expansion on the command line:</p>

<pre class="ruby"><span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;echo C*&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-constant">CONTRIBUTING</span>.<span class="ruby-identifier">md</span> <span class="ruby-constant">COPYING</span> <span class="ruby-constant">COPYING</span>.<span class="ruby-identifier">ja</span>
</pre>

<p>Raises an exception if the new process could not execute.</p>

<p><strong>Argument <code>exe_path</code></strong></p>

<p>Argument <code>exe_path</code> is one of the following:</p>
<ul><li>
<p>The string path to an executable to be called.</p>
</li><li>
<p>A 2-element array containing the path to an executable and the string to be used as the name of the executing process.</p>
</li></ul>

<p>Example:</p>

<pre class="ruby"><span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;/usr/bin/date&#39;</span>) <span class="ruby-comment"># =&gt; true # Path to date on Unix-style system.</span>
<span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;foo&#39;</span>)           <span class="ruby-comment"># =&gt; nil  # Command failed.</span>
</pre>

<p>Output:</p>

<pre>Mon Aug 28 11:43:10 AM CDT 2023</pre>

<p>Assigns the command’s error status to <code>$?</code>:</p>

<pre class="ruby"><span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;/usr/bin/date&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-identifier">$?</span>                      <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid 645605 exit 0&gt;</span>
<span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;foo&#39;</span>)           <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-identifier">$?</span>                      <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid 645608 exit 127&gt;</span>
</pre>

<p>Ruby invokes the executable directly, with no shell and no shell expansion:</p>

<pre class="ruby"><span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;doesnt_exist&#39;</span>) <span class="ruby-comment"># =&gt; nil</span>
</pre>

<p>If one or more <code>args</code> is given, each is an argument or option to be passed to the executable:</p>

<pre class="ruby"><span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;echo&#39;</span>, <span class="ruby-string">&#39;C*&#39;</span>)             <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-identifier">system</span>(<span class="ruby-string">&#39;echo&#39;</span>, <span class="ruby-string">&#39;hello&#39;</span>, <span class="ruby-string">&#39;world&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Output:</p>

<pre>C*
hello world</pre>

<p>Raises an exception if the new process could not execute.</p>

                              <div class="method-source-code" id="system-source">
            <pre>static VALUE
rb_f_system(int argc, VALUE *argv, VALUE _)
{
    VALUE execarg_obj = rb_execarg_new(argc, argv, TRUE, TRUE);
    struct rb_execarg *eargp = rb_execarg_get(execarg_obj);

    struct rb_process_status status = {0};
    eargp-&gt;status = &amp;status;

    rb_last_status_clear();

    // This function can set the thread&#39;s last status.
    // May be different from waitpid_state.pid on exec failure.
    rb_pid_t pid = rb_execarg_spawn(execarg_obj, 0, 0);

    if (pid &gt; 0) {
        VALUE status = rb_process_status_wait(pid, 0);

        struct rb_process_status *data = rb_check_typeddata(status, &amp;rb_process_status_type);

        // Set the last status:
        rb_obj_freeze(status);
        GET_THREAD()-&gt;last_status = status;

        if (data-&gt;status == EXIT_SUCCESS) {
            return Qtrue;
        }

        if (data-&gt;error != 0) {
            if (eargp-&gt;exception) {
                VALUE command = eargp-&gt;invoke.sh.shell_script;
                RB_GC_GUARD(execarg_obj);
                rb_syserr_fail_str(data-&gt;error, command);
            }
            else {
                return Qnil;
            }
        }
        else if (eargp-&gt;exception) {
            VALUE command = eargp-&gt;invoke.sh.shell_script;
            VALUE str = rb_str_new_cstr(&quot;Command failed with&quot;);
            rb_str_cat_cstr(pst_message_status(str, data-&gt;status), &quot;: &quot;);
            rb_str_append(str, command);
            RB_GC_GUARD(execarg_obj);
            rb_exc_raise(rb_exc_new_str(rb_eRuntimeError, str));
        }
        else {
            return Qfalse;
        }

        RB_GC_GUARD(status);
    }

    if (eargp-&gt;exception) {
        VALUE command = eargp-&gt;invoke.sh.shell_script;
        RB_GC_GUARD(execarg_obj);
        rb_syserr_fail_str(errno, command);
    }
    else {
        return Qnil;
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-tap" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          tap {|x| block }    &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Yields self to the block, and then returns self. The primary purpose of this method is to “tap into” a method chain, in order to perform operations on intermediate results within the chain.</p>

<pre class="ruby">(<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">10</span>)                  .<span class="ruby-identifier">tap</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;original: #{x}&quot;</span> }
  .<span class="ruby-identifier">to_a</span>                  .<span class="ruby-identifier">tap</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;array:    #{x}&quot;</span> }
  .<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">even?</span> } .<span class="ruby-identifier">tap</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;evens:    #{x}&quot;</span> }
  .<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span><span class="ruby-operator">*</span><span class="ruby-identifier">x</span> }        .<span class="ruby-identifier">tap</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;squares:  #{x}&quot;</span> }
</pre>

                              <div class="method-source-code" id="tap-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/kernel.rb, line 89</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">tap</span>
  <span class="ruby-keyword">yield</span>(<span class="ruby-keyword">self</span>)
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-test" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          test(cmd, file1 [, file2] ) &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Uses the character <code>cmd</code> to perform various tests on <code>file1</code> (first table below) or on <code>file1</code> and <code>file2</code> (second table).</p>

<p><a href="File.html"><code>File</code></a> tests on a single file:</p>

<pre>Cmd    Returns   Meaning
&quot;A&quot;  | Time    | Last access time for file1
&quot;b&quot;  | boolean | True if file1 is a block device
&quot;c&quot;  | boolean | True if file1 is a character device
&quot;C&quot;  | Time    | Last change time for file1
&quot;d&quot;  | boolean | True if file1 exists and is a directory
&quot;e&quot;  | boolean | True if file1 exists
&quot;f&quot;  | boolean | True if file1 exists and is a regular file
&quot;g&quot;  | boolean | True if file1 has the setgid bit set
&quot;G&quot;  | boolean | True if file1 exists and has a group
     |         | ownership equal to the caller&#39;s group
&quot;k&quot;  | boolean | True if file1 exists and has the sticky bit set
&quot;l&quot;  | boolean | True if file1 exists and is a symbolic link
&quot;M&quot;  | Time    | Last modification time for file1
&quot;o&quot;  | boolean | True if file1 exists and is owned by
     |         | the caller&#39;s effective uid
&quot;O&quot;  | boolean | True if file1 exists and is owned by
     |         | the caller&#39;s real uid
&quot;p&quot;  | boolean | True if file1 exists and is a fifo
&quot;r&quot;  | boolean | True if file1 is readable by the effective
     |         | uid/gid of the caller
&quot;R&quot;  | boolean | True if file is readable by the real
     |         | uid/gid of the caller
&quot;s&quot;  | int/nil | If file1 has nonzero size, return the size,
     |         | otherwise return nil
&quot;S&quot;  | boolean | True if file1 exists and is a socket
&quot;u&quot;  | boolean | True if file1 has the setuid bit set
&quot;w&quot;  | boolean | True if file1 exists and is writable by
     |         | the effective uid/gid
&quot;W&quot;  | boolean | True if file1 exists and is writable by
     |         | the real uid/gid
&quot;x&quot;  | boolean | True if file1 exists and is executable by
     |         | the effective uid/gid
&quot;X&quot;  | boolean | True if file1 exists and is executable by
     |         | the real uid/gid
&quot;z&quot;  | boolean | True if file1 exists and has a zero length</pre>

<p>Tests that take two files:</p>

<pre>&quot;-&quot;  | boolean | True if file1 and file2 are identical
&quot;=&quot;  | boolean | True if the modification times of file1
     |         | and file2 are equal
&quot;&lt;&quot;  | boolean | True if the modification time of file1
     |         | is prior to that of file2
&quot;&gt;&quot;  | boolean | True if the modification time of file1
     |         | is after that of file2</pre>

                              <div class="method-source-code" id="test-source">
            <pre>static VALUE
rb_f_test(int argc, VALUE *argv, VALUE _)
{
    int cmd;

    if (argc == 0) rb_check_arity(argc, 2, 3);
    cmd = NUM2CHR(argv[0]);
    if (cmd == 0) {
        goto unknown;
    }
    if (strchr(&quot;bcdefgGkloOprRsSuwWxXz&quot;, cmd)) {
        CHECK(1);
        switch (cmd) {
          case &#39;b&#39;:
            return rb_file_blockdev_p(0, argv[1]);

          case &#39;c&#39;:
            return rb_file_chardev_p(0, argv[1]);

          case &#39;d&#39;:
            return rb_file_directory_p(0, argv[1]);

          case &#39;e&#39;:
            return rb_file_exist_p(0, argv[1]);

          case &#39;f&#39;:
            return rb_file_file_p(0, argv[1]);

          case &#39;g&#39;:
            return rb_file_sgid_p(0, argv[1]);

          case &#39;G&#39;:
            return rb_file_grpowned_p(0, argv[1]);

          case &#39;k&#39;:
            return rb_file_sticky_p(0, argv[1]);

          case &#39;l&#39;:
            return rb_file_symlink_p(0, argv[1]);

          case &#39;o&#39;:
            return rb_file_owned_p(0, argv[1]);

          case &#39;O&#39;:
            return rb_file_rowned_p(0, argv[1]);

          case &#39;p&#39;:
            return rb_file_pipe_p(0, argv[1]);

          case &#39;r&#39;:
            return rb_file_readable_p(0, argv[1]);

          case &#39;R&#39;:
            return rb_file_readable_real_p(0, argv[1]);

          case &#39;s&#39;:
            return rb_file_size_p(0, argv[1]);

          case &#39;S&#39;:
            return rb_file_socket_p(0, argv[1]);

          case &#39;u&#39;:
            return rb_file_suid_p(0, argv[1]);

          case &#39;w&#39;:
            return rb_file_writable_p(0, argv[1]);

          case &#39;W&#39;:
            return rb_file_writable_real_p(0, argv[1]);

          case &#39;x&#39;:
            return rb_file_executable_p(0, argv[1]);

          case &#39;X&#39;:
            return rb_file_executable_real_p(0, argv[1]);

          case &#39;z&#39;:
            return rb_file_zero_p(0, argv[1]);
        }
    }

    if (strchr(&quot;MAC&quot;, cmd)) {
        struct stat st;
        VALUE fname = argv[1];

        CHECK(1);
        if (rb_stat(fname, &amp;st) == -1) {
            int e = errno;
            FilePathValue(fname);
            rb_syserr_fail_path(e, fname);
        }

        switch (cmd) {
          case &#39;A&#39;:
            return stat_atime(&amp;st);
          case &#39;M&#39;:
            return stat_mtime(&amp;st);
          case &#39;C&#39;:
            return stat_ctime(&amp;st);
        }
    }

    if (cmd == &#39;-&#39;) {
        CHECK(2);
        return rb_file_identical_p(0, argv[1], argv[2]);
    }

    if (strchr(&quot;=&lt;&gt;&quot;, cmd)) {
        struct stat st1, st2;
        struct timespec t1, t2;

        CHECK(2);
        if (rb_stat(argv[1], &amp;st1) &lt; 0) return Qfalse;
        if (rb_stat(argv[2], &amp;st2) &lt; 0) return Qfalse;

        t1 = stat_mtimespec(&amp;st1);
        t2 = stat_mtimespec(&amp;st2);

        switch (cmd) {
          case &#39;=&#39;:
            if (t1.tv_sec == t2.tv_sec &amp;&amp; t1.tv_nsec == t2.tv_nsec) return Qtrue;
            return Qfalse;

          case &#39;&gt;&#39;:
            if (t1.tv_sec &gt; t2.tv_sec) return Qtrue;
            if (t1.tv_sec == t2.tv_sec &amp;&amp; t1.tv_nsec &gt; t2.tv_nsec) return Qtrue;
            return Qfalse;

          case &#39;&lt;&#39;:
            if (t1.tv_sec &lt; t2.tv_sec) return Qtrue;
            if (t1.tv_sec == t2.tv_sec &amp;&amp; t1.tv_nsec &lt; t2.tv_nsec) return Qtrue;
            return Qfalse;
        }
    }
  unknown:
    /* unknown command */
    if (ISPRINT(cmd)) {
        rb_raise(rb_eArgError, &quot;unknown command &#39;%s%c&#39;&quot;, cmd == &#39;\&#39;&#39; || cmd == &#39;\\&#39; ? &quot;\\&quot; : &quot;&quot;, cmd);
    }
    else {
        rb_raise(rb_eArgError, &quot;unknown command \&quot;\\x%02X\&quot;&quot;, cmd);
    }
    UNREACHABLE_RETURN(Qundef);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-then" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          then {|x| block }          &rarr; an_object
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Yields self to the block and returns the result of the block.</p>

<pre class="ruby"><span class="ruby-value">3</span>.<span class="ruby-identifier">next</span>.<span class="ruby-identifier">then</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span><span class="ruby-operator">**</span><span class="ruby-identifier">x</span> }.<span class="ruby-identifier">to_s</span>             <span class="ruby-comment">#=&gt; &quot;256&quot;</span>
</pre>

<p>Good usage for <code>then</code> is value piping in method chains:</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;open-uri&#39;</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&#39;json&#39;</span>

<span class="ruby-identifier">construct_url</span>(<span class="ruby-identifier">arguments</span>).
  <span class="ruby-identifier">then</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">url</span><span class="ruby-operator">|</span> <span class="ruby-constant">URI</span>(<span class="ruby-identifier">url</span>).<span class="ruby-identifier">read</span> }.
  <span class="ruby-identifier">then</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">response</span><span class="ruby-operator">|</span> <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">response</span>) }
</pre>

<p>When called without block, the method returns <code>Enumerator</code>, which can be used, for example, for conditional circuit-breaking:</p>

<pre class="ruby"><span class="ruby-comment"># meets condition, no-op</span>
<span class="ruby-value">1</span>.<span class="ruby-identifier">then</span>.<span class="ruby-identifier">detect</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:odd?</span>)            <span class="ruby-comment"># =&gt; 1</span>
<span class="ruby-comment"># does not meet condition, drop value</span>
<span class="ruby-value">2</span>.<span class="ruby-identifier">then</span>.<span class="ruby-identifier">detect</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:odd?</span>)            <span class="ruby-comment"># =&gt; nil</span>
</pre>

                              <div class="method-source-code" id="then-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/kernel.rb, line 120</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">then</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier ruby-title">block_given?</span>
    <span class="ruby-keyword">return</span> <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">&#39;SIZED_ENUMERATOR(self, 0, 0, rb_obj_size)&#39;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">yield</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-throw" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          throw(tag [, obj])
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Transfers control to the end of the active <code>catch</code> block waiting for <em>tag</em>. Raises <code>UncaughtThrowError</code> if there is no <code>catch</code> block for the <em>tag</em>. The optional second parameter supplies a return value for the <code>catch</code> block, which otherwise defaults to <code>nil</code>. For examples, see Kernel::catch.</p>

                              <div class="method-source-code" id="throw-source">
            <pre>static VALUE
rb_f_throw(int argc, VALUE *argv, VALUE _)
{
    VALUE tag, value;

    rb_scan_args(argc, argv, &quot;11&quot;, &amp;tag, &amp;value);
    rb_throw_obj(tag, value);
    UNREACHABLE_RETURN(Qnil);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-trace_var" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          trace_var(symbol, cmd )             &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          trace_var(symbol) {|val| block }    &rarr; nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Controls tracing of assignments to global variables. The parameter <code>symbol</code> identifies the variable (as either a string name or a symbol identifier). <em>cmd</em> (which may be a string or a <code>Proc</code> object) or block is executed whenever the variable is assigned. The block or <code>Proc</code> object receives the variable’s new value as a parameter. Also see Kernel::untrace_var.</p>

<pre class="ruby"><span class="ruby-identifier">trace_var</span> <span class="ruby-value">:$_</span>, <span class="ruby-identifier">proc</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;$_ is now &#39;#{v}&#39;&quot;</span> }
<span class="ruby-identifier">$_</span> = <span class="ruby-string">&quot;hello&quot;</span>
<span class="ruby-identifier">$_</span> = <span class="ruby-string">&#39; there&#39;</span>
</pre>

<p><em>produces:</em></p>

<pre>$_ is now &#39;hello&#39;
$_ is now &#39; there&#39;</pre>

                              <div class="method-source-code" id="trace_var-source">
            <pre>static VALUE
f_trace_var(int c, const VALUE *a, VALUE _)
{
    return rb_f_trace_var(c, a);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-trap" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          trap( signal, command ) &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          trap( signal ) {| | block } &rarr; obj
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Specifies the handling of signals. The first parameter is a signal name (a string such as “SIGALRM”, “SIGUSR1”, and so on) or a signal number. The characters “SIG” may be omitted from the signal name. The command or block specifies code to be run when the signal is raised. If the command is the string “IGNORE” or “SIG_IGN”, the signal will be ignored. If the command is “DEFAULT” or “SIG_DFL”, the Ruby’s default handler will be invoked. If the command is “EXIT”, the script will be terminated by the signal. If the command is “SYSTEM_DEFAULT”, the operating system’s default handler will be invoked. Otherwise, the given command or block will be run. The special signal name “EXIT” or signal number zero will be invoked just prior to program termination. trap returns the previous handler for the given signal.</p>

<pre class="ruby"><span class="ruby-constant">Signal</span>.<span class="ruby-identifier">trap</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Terminating: #{$$}&quot;</span> })
<span class="ruby-constant">Signal</span>.<span class="ruby-identifier">trap</span>(<span class="ruby-string">&quot;CLD&quot;</span>)  { <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;Child died&quot;</span> }
<span class="ruby-identifier">fork</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">Process</span>.<span class="ruby-identifier">wait</span>
</pre>

<p><em>produces:</em></p>

<pre>Terminating: 27461
Child died
Terminating: 27460</pre>

                              <div class="method-source-code" id="trap-source">
            <pre>static VALUE
sig_trap(int argc, VALUE *argv, VALUE _)
{
    int sig;
    sighandler_t func;
    VALUE cmd;

    rb_check_arity(argc, 1, 2);

    sig = trap_signm(argv[0]);
    if (reserved_signal_p(sig)) {
        const char *name = signo2signm(sig);
        if (name)
            rb_raise(rb_eArgError, &quot;can&#39;t trap reserved signal: SIG%s&quot;, name);
        else
            rb_raise(rb_eArgError, &quot;can&#39;t trap reserved signal: %d&quot;, sig);
    }

    if (argc == 1) {
        cmd = rb_block_proc();
        func = sighandler;
    }
    else {
        cmd = argv[1];
        func = trap_handler(&amp;cmd, sig);
    }

    if (rb_obj_is_proc(cmd) &amp;&amp;
        !rb_ractor_main_p() &amp;&amp; !rb_ractor_shareable_p(cmd)) {
        cmd = rb_proc_isolate(cmd);
    }

    return trap(sig, func, cmd);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-untrace_var" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          untrace_var(symbol [, cmd] )   &rarr; array or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes tracing for the specified command on the given global variable and returns <code>nil</code>. If no command is specified, removes all tracing for that variable and returns an array containing the commands actually removed.</p>

                              <div class="method-source-code" id="untrace_var-source">
            <pre>static VALUE
f_untrace_var(int c, const VALUE *a, VALUE _)
{
    return rb_f_untrace_var(c, a);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-warn" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          warn(*msgs, uplevel: nil, category: nil)   &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>If warnings have been disabled (for example with the <code>-W0</code> flag), does nothing.  Otherwise, converts each of the messages to strings, appends a newline character to the string if the string does not end in a newline, and calls <a href="Warning.html#method-i-warn"><code>Warning.warn</code></a> with the string.</p>

<pre class="ruby"><span class="ruby-identifier">warn</span>(<span class="ruby-string">&quot;warning 1&quot;</span>, <span class="ruby-string">&quot;warning 2&quot;</span>)
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-identifier">warning</span> <span class="ruby-value">1</span>
<span class="ruby-identifier">warning</span> <span class="ruby-value">2</span>
</pre>

<p>If the <code>uplevel</code> keyword argument is given, the string will be prepended with information for the given caller frame in the same format used by the <code>rb_warn</code> C function.</p>

<pre class="ruby"><span class="ruby-comment"># In baz.rb</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">foo</span>
  <span class="ruby-identifier">warn</span>(<span class="ruby-string">&quot;invalid call to foo&quot;</span>, <span class="ruby-value">uplevel:</span> <span class="ruby-value">1</span>)
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">bar</span>
  <span class="ruby-identifier">foo</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">bar</span>
</pre>

<p><em>produces:</em></p>

<pre>baz.rb:6: warning: invalid call to foo</pre>

<p>If <code>category</code> keyword argument is given, passes the category to <code>Warning.warn</code>.  The category given must be be one of the following categories:</p>
<dl class="rdoc-list note-list"><dt>:deprecated 
<dd>
<p>Used for warning for deprecated functionality that may be removed in the future.</p>
</dd><dt>:experimental 
<dd>
<p>Used for experimental features that may change in future releases.</p>
</dd></dl>

                              <div class="method-source-code" id="warn-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/warning.rb, line 50</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">warn</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">msgs</span>, <span class="ruby-value">uplevel:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">category:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">rb_warn_m</span>(<span class="ruby-identifier">msgs</span>, <span class="ruby-identifier">uplevel</span>, <span class="ruby-identifier">category</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-yield_self" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          yield_self {|x| block }    &rarr; an_object
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Yields self to the block and returns the result of the block.</p>

<pre class="ruby"><span class="ruby-string">&quot;my string&quot;</span>.<span class="ruby-identifier">yield_self</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">upcase</span> }   <span class="ruby-comment">#=&gt; &quot;MY STRING&quot;</span>
</pre>

<p>Good usage for <code>then</code> is value piping in method chains:</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;open-uri&#39;</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&#39;json&#39;</span>

<span class="ruby-identifier">construct_url</span>(<span class="ruby-identifier">arguments</span>).
  <span class="ruby-identifier">then</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">url</span><span class="ruby-operator">|</span> <span class="ruby-constant">URI</span>(<span class="ruby-identifier">url</span>).<span class="ruby-identifier">read</span> }.
  <span class="ruby-identifier">then</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">response</span><span class="ruby-operator">|</span> <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">response</span>) }
</pre>

                              <div class="method-source-code" id="yield_self-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/kernel.rb, line 144</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">yield_self</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">block_given?</span>
    <span class="ruby-keyword">return</span> <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">&#39;SIZED_ENUMERATOR(self, 0, 0, rb_obj_size)&#39;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">yield</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-pp" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">pp</span><span
                                class="method-args">(*objs)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>suppress redefinition warning</p>

                              <div class="method-source-code" id="pp-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/prelude.rb, line 13</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pp</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">objs</span>)
  <span class="ruby-identifier">require</span> <span class="ruby-string">&#39;pp&#39;</span>
  <span class="ruby-identifier">pp</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">objs</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: pp
                            </div>

                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

